#54379: fix: stop leaking GDK_BACKEND into child processes on Linux
Description of Change
Fixes #28436.
After this change processes an Electron app launches on Linux (shell.openExternal()'s xdg-open, child_process children, utility processes) no longer inherit a GDK_BACKEND the user did not set, so GTK apps opened from an X11 Electron app in a Wayland session start normally instead of reporting "already running" or falling back to XWayland.
Chromium's GTK integration sets GDK_BACKEND=x11 (or wayland) in the browser environment so gtk_init() picks the backend matching Ozone, and never restores it. #28898 fixed this in 2021 and was reverted in #29610.
This carries the upstream fix, https://chromium-review.googlesource.com/c/chromium/src/+/8468407, as a patch until it rolls in: the variable is set through a ScopedEnvironmentVariableOverride around gtk_init() (as GDK_GL already is) and restored afterwards. A Linux spec launches a fixture app with GDK_BACKEND unset and set to x11 and checks what a grandchild sees; before the patch the unset case reported x11.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
- tests are changed or added
Release Notes
Notes: Fixed GDK_BACKEND leaking into processes spawned by Electron apps on Linux.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron