electron: [Bug]: Electron propagates GDK_BACKEND=x11 to subprocesses, breaking shell.openExternal with Firefox on Wayland

Preflight Checklist

Electron Version

12.0.9 13.0.1 14.1.0 15.1.1

What operating system are you using?

Other Linux

Operating System Version

NixOS 21.05

What arch are you using?

x64

Last Known Working Electron version

12.0.0-beta.20

Expected Behavior

shell.openExternal("https://electronjs.org/") opens a browser tab at https://electronjs.org/. (My browser is Firefox on Wayland with MOZ_ENABLE_WAYLAND=1, and has other tabs already open.)

Actual Behavior

Firefox shows this error and does not open a tab:

“Firefox is already running, but is not responding. To use Firefox, you must first close the existing Firefox process, restart your device, or use a different profile.”

Testcase Gist URL

https://gist.github.com/31ec2165f4aa806536e11d7d99d1e26f

I bisected this to v12.0.0-beta.20…v12.0.0-beta.21 (9faf23509d054062def1332500c05c8ee7fb9bb7…5dbb6356effbfc0f6e0528583fae832290c14207).

The difference between v12.0.0-beta.20’s working invocation of xdg-open and v12.0.0-beta.21’s failing invocation is that the latter has GDK_BACKEND=x11 in the environment. I confirmed that this is responsible for the failure with manual invocations of

xdg-open https://electronjs.org/  # works
env GDK_BACKEND=x11 xdg-open https://electronjs.org/  # fails

I don’t know if Electron or Chromium need to set GDK_BACKEND=x11 for their own purposes, but it definitely should not be propagated to subprocesses such as xdg-open.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 11
  • Comments: 19 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Still an issue in 26.3.0, 27.0.0-beta.9, and 28.0.0-nightly.20231009. Still wilting for #29606/#32929.

Still broken in 24.1.2, 25.0.0-alpha.4, and 26.0.0-nightly.20230421. Still waiting for #29606/#32929.

Just ran into this with VSCodium 1.56. Is there a workaround until this is properly fixed?

EDIT: Workaround: Add /usr/local/bin/xdg-open (assuming /usr/local/bin is in your PATH) with

#!/bin/sh
unset GDK_BACKEND
/usr/bin/xdg-open $@

and make it executable (this is assuming you don’t sometimes need that value, of course).

Stoppp it, bot.

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, “bump”), and we’ll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

The fix in #28898 was reverted in #29610, and has not yet been reapplied in #29606. This still reproduces in 14.1.0 and 15.1.1. Please reopen.

Yup that is correct, I did mean removing the environment set by chromium in the parent process.