Skip to content

fix: add Wayland support#26022

Merged
codebytere merged 1 commit intoelectron:masterfrom
vially:wayland
Oct 20, 2020
Merged

fix: add Wayland support#26022
codebytere merged 1 commit intoelectron:masterfrom
vially:wayland

Conversation

@vially
Copy link
Copy Markdown
Contributor

@vially vially commented Oct 18, 2020

Description of Change

Add initial support for running Electron on Wayland (#10915).

Since version 87, Wayland support is enabled in the default Chromium build and can be enabled at runtime with a feature flag: --enable-features=UseOzonePlatform --ozone-platform=wayland (chromium#1085700).

This pull-request attempts to do the same for Electron. This means that the non-Ozone X11 is still the default but Ozone/Wayland and Ozone/X11 can now be chosen at runtime using this feature flag:

electron --enable-features=UseOzonePlatform --ozone-platform=wayland
electron --enable-features=UseOzonePlatform --ozone-platform=x11

The Wayland support is very experimental and various features which were working in X11 may either be broken or not implemented for Wayland.

Therefore, this pull-request should be seen more like the minimal amount of changes required to show an Electron window in Wayland rather than the complete set of changes required to bring full Wayland support to Electron.

Build configuration

I'm not familiar with Electron's CI build system but there's a chance it might require some changes to accommodate Wayland support on Linux. If it turns out that's the case I might need some help from someone familiar with these systems.

FWIW, this is the build tools config that I've used locally to build and test this:

GN gen args
{
  "goma": "cache-only",
  "root": "/home/vially/projects/electron",
  "gen": {
    "args": [
      "import(\"//electron/build/args/testing.gn\")",
      "import(\"/home/vially/.electron_build_tools/third_party/goma.gn\")",
      "blink_symbol_level=0",
      "icu_use_data_file=false",
      "is_component_ffmpeg=false",
      "link_pulseaudio=true",
      "treat_warnings_as_errors=false",
      "use_gnome_keyring=false",
      "use_sysroot=false",
      "use_ozone=true",
      "ozone_auto_platforms=false",
      "ozone_platform_wayland=true",
      "ozone_platform_x11=true",
      "use_system_libwayland=true",
      "use_glib=true",
      "rtc_use_pipewire=true"
    ],
    "out": "Testing"
  },
  "env": {
    "CHROMIUM_BUILDTOOLS_PATH": "/home/vially/projects/electron/src/buildtools",
    "GIT_CACHE_PATH": "/home/vially/.git_cache"
  },
  "remotes": {
    "electron": {
      "origin": "git@github.com:electron/electron.git",
      "hedgepigdaniel": "git@github.com:hedgepigdaniel/electron.git",
      "fork": "git@github.com:vially/electron.git"
    },
    "node": {
      "origin": "git@github.com:electron/node.git"
    }
  }
}

Acknowledgements

Thank you @hedgepigdaniel for providing the set of patches that this pull-request was based on. Also a big thank you to @msisov, @nickdiego, @tonikitoo and many others from the @Igalia team for adding Wayland support to Chromium.

Checklist

Release Notes

Notes: none

@electron-cation electron-cation bot added new-pr 🌱 PR opened recently and removed new-pr 🌱 PR opened recently labels Oct 18, 2020
@zcbenz zcbenz requested a review from ckerr October 19, 2020 11:53
Copy link
Copy Markdown
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great start. Thanks for doing this work!

@codebytere codebytere merged commit c4525b4 into electron:master Oct 20, 2020
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Oct 20, 2020

No Release Notes

@vially vially deleted the wayland branch October 20, 2020 18:25
@deepak1556
Copy link
Copy Markdown
Member

Thanks for the PR, question about the gn args used, I see you had built with "use_sysroot=false". Is there a missing dependency we need add to our sysroot ?

@vially
Copy link
Copy Markdown
Contributor Author

vially commented Oct 20, 2020

I see you had built with "use_sysroot=false". Is there a missing dependency we need add to our sysroot?

I'm not sure to be honest. I only used "use_sysroot=false" in my config because that's what is used in the Archlinux electron package build script and it was the easiest way to get started building Electron on my machine. And since it worked I never payed any attention to it or bothered changing the build configuration.

I'll try to build with "use_sysroot=true" and report back here the results. If I find out that there are indeed missing dependencies in the Electron sysroot I'll submit a pull-request to add them (I guess debian-sysroot-image-creator is the right repository for that).

@deepak1556
Copy link
Copy Markdown
Member

Thanks!

I guess debian-sysroot-image-creator is the right repository for that).

yup thats correct.

@vially
Copy link
Copy Markdown
Contributor Author

vially commented Oct 22, 2020

Building with "use_sysroot=true" seems to work fine and the build seems to run fine both on Wayland and on X11. I suppose this means there are no missing Wayland dependencies in the Electron sysroot. @deepak1556

GN args (use_sysroot=true)
{
  "goma": "cache-only",
  "root": "/home/vially/projects/electron",
  "gen": {
    "args": [
      "import(\"//electron/build/args/testing.gn\")",
      "import(\"/home/vially/.electron_build_tools/third_party/goma.gn\")",
      "use_sysroot=true"
    ],
    "out": "Testing"
  },
  "env": {
    "CHROMIUM_BUILDTOOLS_PATH": "/home/vially/projects/electron/src/buildtools",
    "GIT_CACHE_PATH": "/home/vially/.git_cache"
  },
  "remotes": {
    "electron": {
      "origin": "git@github.com:electron/electron.git",
      "hedgepigdaniel": "git@github.com:hedgepigdaniel/electron.git",
      "fork": "git@github.com:vially/electron.git"
    },
    "node": {
      "origin": "git@github.com:electron/node.git"
    }
  }
}

@bernharl
Copy link
Copy Markdown

When will this be in a release?

@ovflowd
Copy link
Copy Markdown

ovflowd commented Oct 25, 2020

As part of the GNOME Team, I'm genuinely excited to see this happening.

Thank you for all the efforts, Electron contributors!

We at GNOME, say thank you!

@vially
Copy link
Copy Markdown
Contributor Author

vially commented Oct 25, 2020

When will this be in a release?

Unless additional issues are uncovered which will make it necessary to revert this pull-request I think this will land in Electron 12.

However, as I've mentioned in the description, this is still very experimental so bugs and missing features are to be expected in the first release.

@fosskers
Copy link
Copy Markdown

fosskers commented Mar 4, 2021

Just a double-check: was this actually included in Electron 12?

@vially
Copy link
Copy Markdown
Contributor Author

vially commented Mar 8, 2021

@fosskers Sorry, I somehow missed this notification and I guess you must have gotten your answer by now. But in case you haven't, yes, it has landed in version 12 (:tada:) and can be tested by running:

electron --enable-features=UseOzonePlatform --ozone-platform=wayland

@fosskers
Copy link
Copy Markdown

fosskers commented Mar 8, 2021

Thanks @vially I'm sure there are many people who would be happy to hear that!

SISheogorath added a commit to flathub/im.riot.Riot that referenced this pull request Apr 15, 2021
After thinking about it a few times, I finally decided to add the
wayland socket permission to the flatpak. While it's not strictly
necessary it also doesn't hurt much, but simplifies the usage of the
upcoming support for the electron wayland integration.

Further references:
#173
electron/electron#26022
@RangerMauve
Copy link
Copy Markdown

Has anybody managed to set these flags at runtime?

I'm working on a Web browser and currently getting it to work on the Pinephone. When I don't use these flags the text gets all fuzzy due to the scaling.

Adding the flags in works great and fixes the fuzziness and makes it more snappy overall. However, this only works if I add the flags on the CLI. If I try to specify the flags in webPreferences.additionalArguments or commandLine.appendSwitch it doesn't seem to have the desired effect. It either does nothing, or leads to a gray screen.

Has anybody seen this issue, or is there another place I should be specifying arguments that would work better?

su-ex pushed a commit to flathub/chat.schildi.desktop that referenced this pull request Jun 3, 2021
After thinking about it a few times, I finally decided to add the
wayland socket permission to the flatpak. While it's not strictly
necessary it also doesn't hurt much, but simplifies the usage of the
upcoming support for the electron wayland integration.

Further references:
flathub/im.riot.Riot#173
electron/electron#26022
su-ex pushed a commit to flathub/chat.schildi.desktop that referenced this pull request Jun 3, 2021
After thinking about it a few times, I finally decided to add the
wayland socket permission to the flatpak. While it's not strictly
necessary it also doesn't hurt much, but simplifies the usage of the
upcoming support for the electron wayland integration.

Further references:
flathub/im.riot.Riot#173
electron/electron#26022
ckerr added a commit that referenced this pull request Jan 26, 2024
…ed()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4710351

Xref: #26022

This usage was added in #26022 as part of Wayland support and some
simple fiddles WfM with this patch on Wayland, but I'm unsure what
to be testing for & would like a second opinion on this commit.
jkleinsc pushed a commit that referenced this pull request Jan 31, 2024
…ed()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4710351

Xref: #26022

This usage was added in #26022 as part of Wayland support and some
simple fiddles WfM with this patch on Wayland, but I'm unsure what
to be testing for & would like a second opinion on this commit.
jkleinsc pushed a commit that referenced this pull request Jan 31, 2024
…ed()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4710351

Xref: #26022

This usage was added in #26022 as part of Wayland support and some
simple fiddles WfM with this patch on Wayland, but I'm unsure what
to be testing for & would like a second opinion on this commit.
ckerr added a commit that referenced this pull request Jan 31, 2024
* chore: bump chromium in DEPS to 123.0.6265.0

* chore: bump chromium in DEPS to 123.0.6266.0

* chore: update feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5232280

reverts the revert *and* undoes the rewrites 😵

* chore: update chromium/disable_hidden.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

minor manual intervention

* chore: update patches

* chore: Rename mouse lock to pointer lock

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

* refactor: fix use of newly-removed QuitCurrentWhenIdleClosureDeprecated()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4710351

Xref: #26022

This usage was added in #26022 as part of Wayland support and some
simple fiddles WfM with this patch on Wayland, but I'm unsure what
to be testing for & would like a second opinion on this commit.

* chore: bump chromium in DEPS to 123.0.6268.0

* chore: update patches

* 5235021: WebUI: Migrate accessibility and bluetooth internals to WebUIConfig
https://chromium-review.googlesource.com/c/chromium/src/+/5235021

* address review comment for 5196547

See: https://chromium-review.googlesource.com/c/chromium/src/+/5196547
Review comment: #41130 (comment)

* 5075962: Introduce URLLoaderFactoryBuilder
https://chromium-review.googlesource.com/c/chromium/src/+/5075962

* chore: bump chromium in DEPS to 123.0.6270.0

* the missing semicolon strikes again

* chore: update chromium patches

* chore: update v8 patches

* 5242326: Some followup cleanup to Fuchia files in chrome | https://chromium-review.googlesource.com/c/chromium/src/+/5242326

* chore: bump chromium in DEPS to 123.0.6272.0

* chore: update patches

* chore: update patch after rebase

* 5247339: [Clipboard] Remove ClipboardContentType enum.

https://chromium-review.googlesource.com/c/chromium/src/+/5247339

* Reland: "Allow content shell to enable the built-in DNS resolver"

https://chromium-review.googlesource.com/c/chromium/src/+/5232354

* 5018206: [accessibility] Migrate to ScopedAccessibilityMode

https://chromium-review.googlesource.com/c/chromium/src/+/5018206

* 5246669: [Default Nav Transition]Add GetBackForwardTransitionAnimationManager on WebContentsView | https://chromium-review.googlesource.com/c/chromium/src/+/5246669

* fix: move nut-js to optional spec deps (#41199)

* chore: bump chromium in DEPS to 123.0.6265.0

* chore: bump chromium in DEPS to 123.0.6266.0

* chore: update feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5232280

reverts the revert *and* undoes the rewrites 😵

* chore: update chromium/disable_hidden.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

minor manual intervention

* chore: update patches

* chore: Rename mouse lock to pointer lock

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

* refactor: fix use of newly-removed QuitCurrentWhenIdleClosureDeprecated()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4710351

Xref: #26022

This usage was added in #26022 as part of Wayland support and some
simple fiddles WfM with this patch on Wayland, but I'm unsure what
to be testing for & would like a second opinion on this commit.

* chore: bump chromium in DEPS to 123.0.6268.0

* chore: update patches

* 5235021: WebUI: Migrate accessibility and bluetooth internals to WebUIConfig
https://chromium-review.googlesource.com/c/chromium/src/+/5235021

* address review comment for 5196547

See: https://chromium-review.googlesource.com/c/chromium/src/+/5196547
Review comment: #41130 (comment)

* 5075962: Introduce URLLoaderFactoryBuilder
https://chromium-review.googlesource.com/c/chromium/src/+/5075962

* chore: bump chromium in DEPS to 123.0.6270.0

* the missing semicolon strikes again

* chore: update chromium patches

* chore: update v8 patches

* 5242326: Some followup cleanup to Fuchia files in chrome | https://chromium-review.googlesource.com/c/chromium/src/+/5242326

* chore: bump chromium in DEPS to 123.0.6272.0

* chore: update patches

* chore: update patch after rebase

* 5247339: [Clipboard] Remove ClipboardContentType enum.

https://chromium-review.googlesource.com/c/chromium/src/+/5247339

* Reland: "Allow content shell to enable the built-in DNS resolver"

https://chromium-review.googlesource.com/c/chromium/src/+/5232354

* 5018206: [accessibility] Migrate to ScopedAccessibilityMode

https://chromium-review.googlesource.com/c/chromium/src/+/5018206

* 5246669: [Default Nav Transition]Add GetBackForwardTransitionAnimationManager on WebContentsView | https://chromium-review.googlesource.com/c/chromium/src/+/5246669

* fix: typescript error for optional dependency

(cherry picked from commit ea17105)

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: VerteDinde <vertedinde@electronjs.org>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Sam Maddock <smaddock@slack-corp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants