Repository: lutris/lutris

Issue:
Lutris 0.5.14 sometimes crashes when accessing Settings > Global options
### Bug description

Lutris 0.5.14 sometimes crashes when accessing Settings > Global options in Fedora 38 KDE (wayland session). It also sometimes happens when accessing "System options" section of a Runner's options.

dmesg shows this:
lutris[2046611] general protection fault ip:7f0b2e59ad33 sp:7f0b090baf60 error:0 in libglib-2.0.so.0.7600.5[7f0b2e53a000+a0000]
lutris[3245093] general protection fault ip:7f6b3702f260 sp:7f6b12abad50 error:0 in libpango-1.0.so.0.5000.14[7f6b3700e000+39000]

I am sometimes shown this in lutris output:
Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
**
Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
fish: Job 1, '/usr/bin/lutris' terminated by signal SIGABRT (Abort)

### How to Reproduce

Steps to reproduce the behavior:
1. Open lutris
2. Go to settings > global options
3. Sometimes it will crash

### Expected behavior

Not crash when accessing certain settings pages

### Log output

```shell
DEBUG    2023-10-22 11:48:09,938 [lutris.get_missing_game_ids:202]:Checking for missing games
DEBUG    2023-10-22 11:48:13,497 [application.show_window:359]:Showing window PreferencesDialog{'parent': <lutriswindow.LutrisWindow object at 0x7f531d6e3000 (LutrisWindow at 0x55a33ac56f90)>}
DEBUG    2023-10-22 11:48:15,002 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-10-22 11:48:15,015 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-10-22 11:48:15,053 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-10-22 11:48:15,062 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-10-22 11:48:15,068 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
**
Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
**
Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
fish: Job 1, '/usr/bin/lutris -d' terminated by signal SIGABRT (Abort)
```


### System Information

```shell
[System]
OS:              Fedora Linux 38 KDE Plasma
Arch:            x86_64
Kernel:          6.5.7-200.fc38.x86_64
Desktop:         KDE
Display Server:  wayland

[CPU]
Vendor:          GenuineIntel
Model:           Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
Physical cores:  2
Logical cores:   4

[Memory]
RAM:             7.6 GB
Swap:            7.6 GB

[Graphics]
Vendor:          Intel
OpenGL Renderer: Mesa Intel(R) HD Graphics 620 (KBL GT2)
OpenGL Version:  4.6 (Compatibility Profile) Mesa 23.1.8
OpenGL Core:     4.6 (Core Profile) Mesa 23.1.8
OpenGL ES:       OpenGL ES 3.2 Mesa 23.1.8
Vulkan Version:  1.3.243
Vulkan Drivers:  Intel(R) HD Graphics 620 (KBL GT2) (1.3.246)
```


### Media (optional)

_No response_

### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:
Hmm. Did this happen in 0.5.13? I notice it refers to libpango, and we've started using Pango- to write the 'Missing' badge on the media for games whose directory is missing.

Try this: Go into Preferences and activate the option to "Hide badges on icons"; then *restart Lutris*. Now, go into settings and try those options again. Does it still crash?

It still crashes sometimes when that option is checked.
Hmm, so much for that theory. If it's not that little badge, I'm not sure what's happened in 0.5.14 that's affecting you. It's GTK that's blowing up, I think. Maybe it's related to KDE somehow?

I'm just guessing at this point.
I can confirm. 
1 - Open Lutris
2 - Right Click a game and select Configure
3 - Click System Options just after opening Lutris
4 - Crash....
BUT
1 - Open Lutris
2 - Right clicking a game and select Configure
3 - Click Runner options
4 - Scroll a bit towards the bottom
5 - Click System Options
6 - No Longer Crashes

OS: EndeavourOS Linux x86_64 
Kernel: 6.5.7
CPU: Intel i5-8600K (6) @ 4.300GHz 
GPU: NVIDIA GeForce RTX 2070 Rev. A 
Memory: 32035MiB
KDE Plasma
Seems like maybe KDE Plasma is the common factor here.
The system tab is making calls to various tools like xrandr and vulkan-info so that's probably what's crashing Lutris on some KDE setups. 
On the Steam Deck's KDE with Lutris flatpak, no issue to report.
Lutris with --debug:

![lutris1](https://github.com/lutris/lutris/assets/4363770/689bf0cf-42ce-4e9f-8185-2e33c4b045f9)

Dmesg shows this:

![lutris_dmesg](https://github.com/lutris/lutris/assets/4363770/6a980382-5e87-4624-884f-75e0cb1b9496)

EDIT:
Sometimes this also shows up in Dmesg:

![lutris3](https://github.com/lutris/lutris/assets/4363770/0ac06258-30ab-4250-b590-14fdfb31c5c8)

Looks like  the xrandr calls are getting through so it's probably vulkan-info that is causing the issue, or more precisely, how python retrieves the output of vulkan-info and loads it in the UI
I'm immediately suspicious of the vkquery stuff. If the C API declarations are wrong...
This is happening for me as well. Running `lutris --debug` the output I get is the same as the one @FSKiller posted.

System Info:
```
[System]
OS:              Arch Linux rolling n/a
Arch:            x86_64
Kernel:          6.5.9-zen2-1-zen
Desktop:         KDE
Display Server:  x11

[CPU]
Vendor:          GenuineIntel
Model:           Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Physical cores:  4
Logical cores:   8

[Memory]
RAM:             15.5 GB
Swap:            7.8 GB

[Graphics]
Vendor:          Intel
OpenGL Renderer: Mesa Intel(R) HD Graphics 530 (SKL GT2)
OpenGL Version:  4.6 (Compatibility Profile) Mesa 23.2.1-arch1.2
OpenGL Core:     4.6 (Core Profile) Mesa 23.2.1-arch1.2
OpenGL ES:       OpenGL ES 3.2 Mesa 23.2.1-arch1.2
Vulkan Version:  1.3.269
Vulkan Drivers:  Intel(R) HD Graphics 530 (SKL GT2) (1.3.255), NVIDIA GeForce 940M (1.3.242)
```
I consistently get segfaults/coredumps when going to "System Options" of a game as well:

```bash
$ lutris
2023-11-03 00:21:59,153: Command 'fluidsynth' not found on your system
2023-11-03 00:21:59,625: Starting Lutris 0.5.14
2023-11-03 00:21:59,628: Using NVIDIA drivers 535.113.01 for x86_64
2023-11-03 00:21:59,628: GPU: NVIDIA GeForce GTX 960M
2023-11-03 00:21:59,628: GPU: 8086:191B 17AA:3802 (i915 drivers)
2023-11-03 00:21:59,628: GPU: 10DE:139B 17AA:3802 (nvidia drivers)
Segmentation fault (core dumped)
```

```bash
$ lutris
2023-11-03 00:22:18,321: Command 'fluidsynth' not found on your system
2023-11-03 00:22:18,804: Starting Lutris 0.5.14
2023-11-03 00:22:18,807: Using NVIDIA drivers 535.113.01 for x86_64
2023-11-03 00:22:18,807: GPU: NVIDIA GeForce GTX 960M
2023-11-03 00:22:18,807: GPU: 8086:191B 17AA:3802 (i915 drivers)
2023-11-03 00:22:18,807: GPU: 10DE:139B 17AA:3802 (nvidia drivers)
corrupted size vs. prev_size
Aborted (core dumped)
```

```bash
$ lutris --debug
2023-11-03 00:30:07,333: Command 'fluidsynth' not found on your system
INFO     2023-11-03 00:30:07,822 [application.do_command_line:436]:Starting Lutris 0.5.14
INFO     2023-11-03 00:30:07,824 [startup.get_drivers:57]:Using NVIDIA drivers 535.113.01 for x86_64
INFO     2023-11-03 00:30:07,825 [startup.get_drivers:61]:GPU: NVIDIA GeForce GTX 960M
INFO     2023-11-03 00:30:07,825 [display.display_gpu_info:78]:GPU: 8086:191B 17AA:3802 (i915 drivers)
INFO     2023-11-03 00:30:07,825 [display.display_gpu_info:78]:GPU: 10DE:139B 17AA:3802 (nvidia drivers)
DEBUG    2023-11-03 00:30:08,300 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-03 00:30:09,407 [lutris.get_missing_game_ids:202]:Checking for missing games
DEBUG    2023-11-03 00:30:15,064 [application.show_window:359]:Showing window EditGameConfigDialog1
DEBUG    2023-11-03 00:30:17,727 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-03 00:30:18,002 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-03 00:30:18,118 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-03 00:30:18,178 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-03 00:30:18,247 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-03 00:30:28,467 [game.save:429]:Saving The Iron Oath (wine) with config ID the-iron-oath-1698958502
DEBUG    2023-11-03 00:30:28,467 [config.save:227]:Saving LutrisConfig(level=game, game_config_id=the-iron-oath-1698958502, runner=wine) config to /home/falk/.config/lutris/games/the-iron-oath-1698958502.yml
DEBUG    2023-11-03 00:30:29,756 [lutris.add_to_path_cache:160]:Adding The Iron Oath (wine) to path cache
DEBUG    2023-11-03 00:30:29,775 [application.on_app_window_destroyed:377]:Removed window EditGameConfigDialog1
DEBUG    2023-11-03 00:30:33,903 [application.show_window:359]:Showing window EditGameConfigDialog1
malloc(): unaligned tcache chunk detected
Aborted (core dumped)
```

```bash
$ inxi -F
System:
  Host: aska Kernel: 6.5.9-arch2-1 arch: x86_64 bits: 64 Desktop: KDE Plasma
    v: 5.27.9 Distro: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 80NV v: Lenovo ideapad Y700-15ISK
    serial: <superuser required>
  Mobo: LENOVO model: Allsparks 5A v: SDK0J40709 WIN
    serial: <superuser required> UEFI: LENOVO v: CDCN54WW date: 06/13/2017
Battery:
  ID-1: BAT0 charge: 43.8 Wh (100.0%) condition: 43.8/60.0 Wh (73.0%)
CPU:
  Info: quad core model: Intel Core i5-6300HQ bits: 64 type: MCP cache:
    L2: 1024 KiB
  Speed (MHz): avg: 800 min/max: 800/3200 cores: 1: 800 2: 800 3: 800 4: 800
Graphics:
  Device-1: Intel HD Graphics 530 driver: i915 v: kernel
  Device-2: NVIDIA GM107M [GeForce GTX 960M] driver: nvidia v: 535.113.01
  Device-3: Intel RealSense 3D Camera (Front F200) driver: uvcvideo
    type: USB
  Display: x11 server: X.Org v: 21.1.9 with: Xwayland v: 23.2.2 driver: X:
    loaded: modesetting,nvidia dri: iris gpu: i915 resolution: 1: 2560x1440~60Hz
    2: N/A
  API: EGL v: 1.5 drivers: nvidia platforms: gbm
  API: OpenGL v: 4.6.0 vendor: nvidia v: 535.113.01 renderer: NVIDIA
    GeForce GTX 960M/PCIe/SSE2
  API: Vulkan v: 1.3.269 drivers: nvidia surfaces: xcb,xlib
Audio:
  Device-1: Intel 100 Series/C230 Series Family HD Audio driver: snd_hda_intel
  API: ALSA v: k6.5.9-arch2-1 status: kernel-api
  Server-1: PipeWire v: 0.3.83 status: active
Network:
  Device-1: Intel Dual Band Wireless-AC 3165 Plus Bluetooth driver: iwlwifi
  IF: wlp8s0 state: up mac: 84:ef:18:ad:a4:58
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    driver: r8169
  IF: enp9s0 state: down mac: c8:5b:76:5e:63:af
  IF-ID-1: nordlynx state: unknown speed: N/A duplex: N/A mac: N/A
Bluetooth:
  Device-1: N/A driver: btusb type: USB
  Report: btmgmt ID: hci0 state: up address: 84:EF:18:AD:A4:5C bt-v: 4.2
Drives:
  Local Storage: total: 4.51 TiB used: 2.72 TiB (60.3%)
  ID-1: /dev/nvme0n1 vendor: Corsair model: Force MP510 size: 894.25 GiB
  ID-2: /dev/sda vendor: Seagate model: BUP BK size: 3.64 TiB type: USB
Partition:
  ID-1: / size: 863.1 GiB used: 192.12 GiB (22.3%) fs: ext4
    dev: /dev/nvme0n1p3
  ID-2: /boot size: 299.4 MiB used: 107.5 MiB (35.9%) fs: vfat
    dev: /dev/nvme0n1p1
Swap:
  ID-1: swap-1 type: partition size: 16 GiB used: 0 KiB (0.0%)
    dev: /dev/nvme0n1p2
Sensors:
  System Temperatures: cpu: 55.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Info:
  Processes: 208 Uptime: 2h 36m Memory: total: 16 GiB available: 15.45 GiB
  used: 5.49 GiB (35.6%) Shell: fish inxi: 3.3.30
```

Hybrid GPU laptop, but I do `optimus-manager --switch nvidia` to toggle the discrete GPU.

Ok, this affects me as well. This bug is really annoying. It never happened for me in 0.5.13, and now it happens almost every time I go into system options.
if only any of the people affected was able to do a bisect. 
I believe I'm seeing it in a Fedora 39 KDE Plasma VM. But it's not reliable at all; seems to crash sometimes if you start Lutris from the panel, go to preferences, and just click among the views for a bit. But more often, no crash.

If I can get a repo out of this VM, I can bisect this. But it's so ghosty right now.

So far, I've seen no crashes when I start from the command line, though it's the same Lutris 0.5.14 from the repo.

~~If somebody else is having this more reliably than I, could try running ``lutris`` from the command line and see if it still crashes? I can't think why this would matter, but...~~

Never mind, I've seen it crash from the command line too. Seems to happen more if I go directly to Global Options and don't visit anything else first.
Well, it's too ghosty to bisect but I tried NOP-ing out the vkquery.py stuff, and it still crashes. So it's not just a messed up declaration in there, at least.
Bisecting led me to this commit https://github.com/lutris/lutris/commit/259c4f43365ee85bfb2f38d132510e41d35917b0
so it's likely in one of the subprocess calls. A crash in vkquery.py would likely produce a better python stacktrace.
> Bisecting led me to this commit [259c4f4](https://github.com/lutris/lutris/commit/259c4f43365ee85bfb2f38d132510e41d35917b0)


that sort of makes sense. That code doesn't even respect the utility functions we have to call subprocess and looks very flimsy. 
Thanks for looking into it.
I also have this issue, but i found a different commit, so i assume its because of a different reason?
For some time Lutris also starts up very slowly (10-30s).

Starts stuttering (~3s) at 2bd88064
Freezes/Crashes at 9acc43b3

I havent tested with a clean config yet.

**System Information**
[System]
OS:              EndeavourOS rolling rolling
Arch:            x86_64
Kernel:          6.6.1-arch1-1
Desktop:         KDE
Display Server:  wayland

[CPU]
Vendor:          AuthenticAMD
Model:           AMD Ryzen 7 5700G with Radeon Graphics
Physical cores:  8
Logical cores:   16

[Memory]
RAM:             30.7 GB
Swap:            8.0 GB

[Graphics]
Vendor:          AMD
OpenGL Renderer: AMD Radeon Graphics (renoir, LLVM 16.0.6, DRM 3.54, 6.6.1-arch1-1)
OpenGL Version:  4.6 (Compatibility Profile) Mesa 23.2.1-arch1.2
OpenGL Core:     4.6 (Core Profile) Mesa 23.2.1-arch1.2
OpenGL ES:       OpenGL ES 3.2 Mesa 23.2.1-arch1.2
Vulkan Version:  1.3.269
Vulkan Drivers:  AMD Radeon Graphics (RADV RENOIR) (1.3.255)

---

Log from 2bd88064
```log
INFO     2023-11-10 20:26:36,597 [startup.init_lutris:173]:Starting Lutris 0.5.12
DEBUG    2023-11-10 20:26:36,615 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
INFO     2023-11-10 20:26:36,631 [startup.check_driver:65]:Running AMD Mesa driver 23.2.1 on AMD Radeon Graphics (renoir, LLVM 16.0.6, DRM 3.54, 6.6.1-arch1-1) (0x1638)
INFO     2023-11-10 20:26:36,631 [startup.check_driver:77]:GPU: 1002:1638 1458:D000 (amdgpu drivers)
DEBUG    2023-11-10 20:26:41,637 [lutriswindow.update_store:450]:Showing 20 games
INFO     2023-11-10 20:26:41,659 [startup.update_runtimes:218]:Startup complete
DEBUG    2023-11-10 20:26:44,006 [application.show_window:330]:Showing window EditGameConfigDialog26
DEBUG    2023-11-10 20:26:45,861 [system.execute:57]:Executing / u s r / b i n / l s p c i
DEBUG    2023-11-10 20:26:45,885 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-10 20:26:45,888 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-10 20:26:45,890 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-10 20:26:54,014 [application.on_app_window_destroyed:348]:Removed window EditGameConfigDialog26
INFO     2023-11-10 20:26:54,017 [application.do_shutdown:943]:Shutting down Lutris
```

---

Log from 9acc43b3
```log
Fr 10. Nov 20:29:44 CET 2023
INFO     2023-11-10 20:29:45,307 [startup.init_lutris:190]:Starting Lutris 0.5.12
DEBUG    2023-11-10 20:29:45,327 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
INFO     2023-11-10 20:29:45,344 [startup.check_driver:72]:Running AMD Mesa driver 23.2.1 on AMD Radeon Graphics (renoir, LLVM 16.0.6, DRM 3.54, 6.6.1-arch1-1) (0x1638)
INFO     2023-11-10 20:29:45,344 [startup.check_driver:84]:GPU: 1002:1638 1458:D000 (amdgpu drivers)
DEBUG    2023-11-10 20:29:53,966 [application.show_window:339]:Showing window EditGameConfigDialog26
DEBUG    2023-11-10 20:29:54,868 [sysoptions.add_icd_search_path:145]:Added '/home/ruakij/.local/share/vulkan' to vulkan ICD search path
DEBUG    2023-11-10 20:29:54,868 [sysoptions.add_icd_search_path:145]:Added '/usr/share/vulkan' to vulkan ICD search path
DEBUG    2023-11-10 20:29:54,868 [sysoptions.get_vk_icd_files:180]:Added '['/usr/share/vulkan/icd.d/nvidia_icd.json', '/usr/share/vulkan/icd.d/radeon_icd.i686.json', '/usr/share/vulkan/icd.d/radeon_icd.x86_64.json']' to all_icd_files
[1]    319093 killed     lutris --debug
Fr 10. Nov 20:30:30 CET 2023
```
Couldnt get it to crash, so killed it instead.

---

Log from 0.5.14 with slow start:
```log
Fr 10. Nov 20:37:35 CET 2023
INFO     2023-11-10 20:37:41,159 [application.do_command_line:436]:Starting Lutris 0.5.14
INFO     2023-11-10 20:37:41,160 [startup.get_drivers:70]:Running AMD Mesa driver 23.2.1 on AMD Radeon Graphics (renoir, LLVM 16.0.6, DRM 3.54, 6.6.1-arch1-1) (0x1638)
INFO     2023-11-10 20:37:41,161 [display.display_gpu_info:78]:GPU: 1002:1638 1458:D000 (amdgpu drivers)
DEBUG    2023-11-10 20:37:51,004 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2023-11-10 20:37:51,771 [lutris.get_missing_game_ids:202]:Checking for missing games
DEBUG    2023-11-10 20:38:02,756 [application.show_window:359]:Showing window PreferencesDialog{'parent': <lutriswindow.LutrisWindow object at 0x7f5b182de700 (LutrisWindow at 0x5636b18d49e0)>}
DEBUG    2023-11-10 20:39:52,422 [application.on_app_window_destroyed:377]:Removed window PreferencesDialog{'parent': <lutriswindow.LutrisWindow object at 0x7f5b182de700 (LutrisWindow at 0x5636b18d49e0)>}
INFO     2023-11-10 20:39:53,801 [application.do_shutdown:1028]:Shutting down Lutris
Fr 10. Nov 20:39:53 CET 2023
```
OK, I've NOPped out the get_locale_list() code and that does seem to avert the crash.

But I also tried to replace the call to Popen with our own system.execute() and that did not help a bit. I do not understand what's causing us to crash here.

I tried switching to locale.locale_alias.values() to get the list, and that crashes, but seems to crash less often.
I think I see it; it's not how we get the locales, it's how big it is. This i a drop down with 873 locales in it on my VM; I think that's triggering a GTK bug of some kind here.

I'll put together a branch that limits the drop down to the UTF-8 options, which are "(recommended)", and you'd have to type in any other locale. Might be an acceptable solution if it works.

Resolving patch:
diff --git a/lutris/gui/config/boxes.py b/lutris/gui/config/boxes.py
--- a/lutris/gui/config/boxes.py
+++ b/lutris/gui/config/boxes.py
@@ -375,14 +375,25 @@ def on_searchable_entry_changed(self, combobox, value, key):
         self.option_changed(combobox, key, value)
 
     def _populate_combobox_choices(self, liststore, choices, default):
+        expanded, tooltip_default = self._expand_combobox_choices(choices, default)
+        for choice in expanded:
+            liststore.append(choice)
+
+        if tooltip_default:
+            self.tooltip_default = tooltip_default
+
+    @staticmethod
+    def _expand_combobox_choices(choices, default):
+        expanded = []
+        tooltip_default = None
         for choice in choices:
             if isinstance(choice, str):
                 choice = (choice, choice)
             if choice[1] == default:
-                liststore.append((_("%s (default)") % choice[0], choice[1]))
-                self.tooltip_default = choice[0]
-            else:
-                liststore.append(choice)
+                tooltip_default = choice[0]
+                choice = (_("%s (default)") % choice[0], choice[1])
+            expanded.append(choice)
+        return expanded, tooltip_default
 
     # ComboBox
     def generate_combobox(self, option_name, choices, label, value=None, default=None, has_entry=False):
@@ -393,21 +404,25 @@ def generate_combobox(self, option_name, choices, label, value=None, default=Non
         if has_entry:
             combobox = Gtk.ComboBox.new_with_model_and_entry(liststore)
             combobox.set_entry_text_column(0)
-            if value:
-                combobox.get_child().set_text(value)
         # No entry ("choice" type)
         else:
             combobox = Gtk.ComboBox.new_with_model(liststore)
             cell = Gtk.CellRendererText()
             combobox.pack_start(cell, True)
             combobox.add_attribute(cell, "text", 0)
-            combobox.set_id_column(1)
 
-            choices = list(v for k, v in choices)
-            if value in choices:
-                combobox.set_active_id(value)
-            else:
-                combobox.set_active_id(default)
+        combobox.set_id_column(1)
+
+        expanded, _tooltip_default = self._expand_combobox_choices(choices, default)
+        if value in [v for _k, v in expanded]:
+            combobox.set_active_id(value)
+        elif has_entry:
+            for ch in combobox.get_children():
+                if isinstance(ch, Gtk.Entry):
+                    ch.set_text(value or "")
+                    break
+        else:
+            combobox.set_active_id(default)
 
         combobox.connect("changed", self.on_combobox_change, option_name)
         combobox.connect("scroll-event", self._on_combobox_scroll)
diff --git a/lutris/sysoptions.py b/lutris/sysoptions.py
--- a/lutris/sysoptions.py
+++ b/lutris/sysoptions.py
@@ -23,18 +23,23 @@ def get_locale_choices():
     """Return list of available locales as label, value tuples
     suitable for inclusion in drop-downs.
     """
-    locales = system.get_locale_list()
-
-    # adds "(recommended)" string to utf8 locales
-    locales_humanized = locales.copy()
-    for index, locale in enumerate(locales_humanized):
-        if "utf8" in locale:
-            locales_humanized[index] += " " + _("(recommended)")
-
-    locale_choices = list(zip(locales_humanized, locales))
-    locale_choices.insert(0, (_("System"), ""))
-
-    return locale_choices
+    return [
+        (_("System"), ""),
+        (_("Chinese"), "zh_CN.utf8"),
+        (_("Croatian"), "hr_HR.utf8"),
+        (_("Dutch"), "nl_NL.utf8"),
+        (_("English"), "en_US.utf8"),
+        (_("Finnish"), "fi_FI.utf8"),
+        (_("Georgian"), "ka_GE.utf8"),
+        (_("German"), "de_DE.utf8"),
+        (_("Italian"), "it_IT.utf8"),
+        (_("Japanese"), "ja_JP.utf8"),
+        (_("Korean"), "ko_KR.utf8"),
+        (_("Portuguese (Brazilian)"), "pt_BR.utf8"),
+        (_("Russian"), "ru_RU.utf8"),
+        (_("Spanish"), "es_ES.utf8"),
+        (_("Turkish"), "tr_TR.utf8"),
+    ]
 
 
 def get_output_choices():
@@ -475,7 +480,7 @@ def get_vk_icd_choices():
     {
         "section": "Game execution",
         "option": "locale",
-        "type": "choice_with_search",
+        "type": "choice_with_entry",
         "label": _("Locale"),
         "choices": (
             get_locale_choices


Test patch: