Skip to content

fix(linux): theme persistence + AppImage EGL crash workaround#36

Open
InstaZDLL wants to merge 2 commits into
mainfrom
fix-theme-persist-webview-crash
Open

fix(linux): theme persistence + AppImage EGL crash workaround#36
InstaZDLL wants to merge 2 commits into
mainfrom
fix-theme-persist-webview-crash

Conversation

@InstaZDLL
Copy link
Copy Markdown
Owner

@InstaZDLL InstaZDLL commented May 17, 2026

Two Linux fixes bundled together — both surface as "app appears broken on Linux" from a user POV.

1. AppImage EGL crash on startup

Symptom: AppImage built on Ubuntu 22 LTS aborts on every distro tested (Ubuntu 22, CachyOS, EndeavourOS, Fedora 44) and inside VMware with:

Could not create default EGL display: EGL_BAD_PARAMETER. Aborting...

Root cause: WebKitGTK ≥ 2.42 enables its DMA-BUF renderer by default, which fails to negotiate an EGL display in the bundled AppImage environment (mismatched Mesa/EGL libs, VM software rasterizer, certain NVIDIA setups).

Fix: Set WEBKIT_DISABLE_DMABUF_RENDERER=1 at the very top of main(), before any GTK/EGL init. Only set if not already provided so power-users can still override.

2. Dark-mode toggle crash (#34)

Symptom: On CachyOS + KDE Plasma Wayland + NVIDIA, clicking the dark-mode toggle freezes the webview ("not responding" dialog).
Root cause: WebKitGTK's View Transitions implementation crashes inside the compositor on some GPU/Wayland stacks. We can't reliably feature-detect which builds are buggy, and gating on userAgent.includes("linux") would kill the animation for every Linux user.
Fix: Persist the next theme value to localStorage before calling startViewTransition. The animation still runs everywhere (no regression for Windows/macOS, Debian, Fedora, healthy Arch setups). If the webview crashes during the transition on the bad stack, the next launch picks up the new theme. Bonus: dark mode now persists across restarts everywhere (previously useState(false) reset on every launch).

Closes #34

Test plan

  • AppImage launches on Ubuntu 22, Fedora 44, CachyOS, EndeavourOS, VMware
  • Toggle theme on Windows / macOS / Linux Debian — animation plays, persists across restart
  • On the buggy CachyOS setup from bug: Dark mode crash #34: click → (crash) → relaunch → app opens in the newly-selected theme
  • Power-user override: launching with WEBKIT_DISABLE_DMABUF_RENDERER=0 keeps the new renderer

Summary by CodeRabbit

Notes de version

  • Corrections de bugs

    • La préférence de thème est désormais lue et restaurée de façon fiable au chargement, même en environnements restreints.
  • Améliorations

    • Changement de thème optimisé : persistance prioritaire et animation "radial reveal" depuis le point de clic sur navigateurs supportés, avec bascule instantanée en fallback.
    • Meilleure robustesse au démarrage sur Linux pour éviter certains échecs liés à l’affichage natif.

Review Change Stack

Save the next theme value to localStorage before triggering
startViewTransition so the choice survives a webview crash on Linux
WebKitGTK with NVIDIA + Wayland (issue #34). Also restore the stored
value on mount so dark mode now persists across launches everywhere.

Closes #34
@github-actions github-actions Bot added scope: frontend React/Vite frontend (src/) type: fix Bug fix size: s 10-50 lines labels May 17, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5aeb5ed9-bcb1-40dd-bb23-8747e4ac6253

📥 Commits

Reviewing files that changed from the base of the PR and between b6190f5 and a73dedb.

📒 Files selected for processing (1)
  • src-tauri/src/main.rs

📝 Walkthrough

Walkthrough

Refactorise ThemeProvider pour lire/écrire la préférence dans localStorage, persister la nouvelle valeur avant basculement, et lancer un "radial reveal" via document.startViewTransition quand disponible. Ajout d'un workaround Linux dans Tauri main() qui définit WEBKIT_DISABLE_DMABUF_RENDERER=1 si absent.

Changes

Persistance des thèmes et animations View Transitions

Couche / Fichier(s) Résumé
Helpers de stockage et initialisation
src/contexts/ThemeContext.tsx
Ajout de THEME_STORAGE_KEY et des fonctions readStoredTheme/writeStoredTheme pour lire/écrire la préférence avec gestion des environnements sans window et des exceptions ; initialisation de isDark depuis le stockage.
Basculement de thème avec persistance et View Transitions
src/contexts/ThemeContext.tsx
toggleTheme refactorisé en useCallback dépendant de isDark. Persistance écrite avant setIsDark. Chemin de repli lorsque document.startViewTransition absent ; sinon préparation puis animation radial reveal via transition.ready et documentElement.animate, avec catch qui maintient l'état déjà togglé.

Workaround WebKitGTK (Linux, Tauri)

Couche / Fichier(s) Résumé
Pré-initialisation Linux dans main.rs
src-tauri/src/main.rs
Insertion d'un bloc Linux-only au début de main() qui définit conditionnellement WEBKIT_DISABLE_DMABUF_RENDERER=1 (via set_var) si la variable est absente, avant toute initialisation GTK/WebKitGTK.

Sequence Diagram

sequenceDiagram
  participant Utilisateur
  participant ThemeProvider
  participant localStorage
  participant ViewTransition
  participant DocumentElement
  Utilisateur->>ThemeProvider: toggleTheme(event)
  ThemeProvider->>localStorage: writeStoredTheme(nextIsDark)
  alt View Transitions disponibles
    ThemeProvider->>ViewTransition: document.startViewTransition()
    ViewTransition->>ThemeProvider: transition.ready
    ThemeProvider->>ThemeProvider: setIsDark(nextIsDark)
    ThemeProvider->>DocumentElement: documentElement.animate(clipPath radial)
  else non supporté
    ThemeProvider->>ThemeProvider: setIsDark(nextIsDark) (instantané)
  end
Loading

Estimated code review effort

🎯 4 (Complexe) | ⏱️ ~40 minutes

Poem

🌙 Le thème s'ancre en local, puis éclate en cercle au clic,
Un rond de lumière part, le code bascule sans panique,
Et sur Linux, une variable veille avant tout départ —
Les ombres et les rendus, tenus sages par le regard. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Le titre suit les Conventional Commits avec un scope valide (linux) et décrit fidèlement les deux corrections principales : persistance du thème et contournement du crash EGL.
Description check ✅ Passed La description remplit tous les éléments critiques du template : résumé détaillé des deux fixes, plan de test, justification fonctionnelle, et fermeture d'issue. Checklist et tests locaux manquent mais les sections de fond sont complètes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-theme-persist-webview-crash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@InstaZDLL InstaZDLL self-assigned this May 17, 2026
@InstaZDLL InstaZDLL linked an issue May 17, 2026 that may be closed by this pull request
AppImage builds abort with `Could not create default EGL display:
EGL_BAD_PARAMETER` on multiple distros (Ubuntu 22, Fedora 44,
Arch/CachyOS/EndeavourOS) and inside VMware. WebKitGTK >= 2.42 uses
the DMA-BUF renderer by default, which fails to negotiate a display
in the bundled AppImage environment. Set the documented workaround
env var at the very top of main() before any GTK/EGL init.
@github-actions github-actions Bot added scope: backend Rust/Tauri backend (src-tauri/) size: m 50-200 lines and removed size: s 10-50 lines labels May 17, 2026
@InstaZDLL InstaZDLL changed the title fix(theme): persist preference before view transition fix(linux): theme persistence + AppImage EGL crash workaround May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: backend Rust/Tauri backend (src-tauri/) scope: frontend React/Vite frontend (src/) size: m 50-200 lines type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Dark mode crash

1 participant