Skip to content

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

Description

@andersk

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 (9faf235...5dbb635).

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.

Activity

  1. codebytere commented on Mar 30, 2021

    @codebytere
    Member
  2. deepak1556 commented on Apr 26, 2021

    @deepak1556
    Member

    Since we inherit the parent process environment for the process launch operation https://github.com/electron/electron/blob/master/shell/common/platform_util_linux.cc#L116 , we should remove GDK_BACKEND from the launch options environment, that can affect external app behaviors.

  3. vially commented on Apr 26, 2021

    @vially
    Contributor

    we should remove GDK_BACKEND from the launch options environment

    But couldn't that potentially cause problems for users who have explicitly set GDK_BACKEND in their environment, but which was then overwritten by Chromium as mentioned above?

    I think ideally Electron should only unset/revert theGDK_BACKEND set by chromium while still keeping the user's original GDK_BACKEND (if set). Maybe something similar to this code block regarding LC_ALL in electron_browser_main_parts.cc.

    Full disclosure: I'm not familiar enough with Electron so maybe I'm totally off here in which case feel free to ignore this.

  4. deepak1556 commented on Apr 26, 2021

    @deepak1556
    Member

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

  5. self-assigned this
    on Apr 28, 2021
  6. jplatte commented on May 11, 2021

    @jplatte

    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).

  7. jplatte commented on May 11, 2021

    @jplatte

    Actually I was getting crashes, not the "not responding" error message. But as noted above, I already put in another workaround.

  8. 62 remaining items

  9. electron-issue-triage commented on Mar 13, 2026

    @electron-issue-triage

    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!

  10. andersk commented on Mar 13, 2026

    @andersk
    ContributorAuthor

    bump

  11. damianremington274-blip commented on Mar 13, 2026

    @damianremington274-blip
  12. electron-issue-triage commented on Jun 17, 2026

    @electron-issue-triage

    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!

  13. andersk commented on Jun 17, 2026

    @andersk
    ContributorAuthor

    bump

  14. electron-issue-triage commented on Sep 17, 2026

    @electron-issue-triage

    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!

  15. andersk commented on Sep 17, 2026

    @andersk
    ContributorAuthor

    bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions