feat(graphics): smart GPU preference with boot watchdog and crash recovery

Solves the long-running performance complaints (especially Optimus
laptops where the dGPU silently hijacks WebKit). The end-to-end shape:

- graphics_detection enumerates physical GPUs from /sys/class/drm and
  cross-references EGL vendor JSONs under /usr/share/glvnd/egl_vendor.d
  to expose only stacks the running process can actually use. Works
  inside Flatpak/Snap because /sys is still mounted read-only and the
  sandbox-visible EGL vendor JSONs are the right thing to read.
- preferred_gpu column in graphics_settings.db (string: auto, integrated,
  discrete, software, or a specific PCI slot id). Migrated with
  ALTER TABLE ... DEFAULT 'auto'.
- env_vars_for_preferred_gpu returns Set/Unset actions applied at startup
  before WebKit init. Integrated/AMD path explicitly unsets
  __NV_PRIME_RENDER_OFFLOAD so KDE/Optimus sessions that pre-set it to 1
  no longer override the EGL pin and yank rendering back onto NVIDIA.
- Auto resolver: on hybrid systems (iGPU + dGPU both usable), Auto pins
  to the iGPU. Single-GPU and no-GPU systems remain no-op. The dropdown
  surfaces what Auto resolved to ("Auto (Intel Graphics)") so the user
  sees the decision without picking explicitly.
- boot_watchdog writes a pending.json before WebKit init listing the
  risky knobs in effect. Frontend calls v2_mark_boot_succeeded after
  first paint to clear it and promote to last-good.json. If the next
  launch sees pending without a success ack, it blames matching fields,
  reverts them in-DB, and increments per-knob failure counters; two
  consecutive failures lock the knob until the user clears it.
- Settings > Graphics gets a Rendering GPU dropdown (between HW accel
  and DMA-BUF) and a crash-recovery banner that lets the user re-enable
  any auto-disabled knob. Restart-required affordance shared with the
  other risky toggles.
- i18n keys for the dropdown, banner copy, and autoWithTarget label
  across all five locales.

cc
This commit is contained in:
vicrodh committed 2026-05-14 00:36:52 -06:00
1 parent 77754e168a
commit b2960e8029
14 files changed
+1391 -5

No files matched your search

+7
View File
@@ -25,6 +25,8 @@ pub fn main_window_built_transparent() -> bool {
}
#[cfg(target_os = "linux")]
pub mod autoconfig_graphics;
pub mod boot_watchdog;
pub mod graphics_detection;
pub mod api;
pub mod api_cache;
@@ -1656,8 +1658,13 @@ pub fn run(qconnect_cli_override: Option<bool>) {
commands_v2::v2_set_gdk_scale,
commands_v2::v2_set_gdk_dpi_scale,
commands_v2::v2_set_gsk_renderer,
commands_v2::v2_set_preferred_gpu,
commands_v2::v2_get_graphics_recommendation,
commands_v2::v2_apply_graphics_recommendation,
commands_v2::v2_enumerate_gpus,
commands_v2::v2_mark_boot_succeeded,
commands_v2::v2_get_crash_flags,
commands_v2::v2_clear_crash_flag,
commands_v2::v2_clear_cache,
commands_v2::v2_clear_artist_cache,
commands_v2::v2_get_vector_store_stats,