NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.39k stars 14.34k forks source link

electron,google-chrome: Ozone/Wayland is broken #158175

Open primeos opened 2 years ago

primeos commented 2 years ago

Electron: Broken since 16.0.6 (or 16.0.5): https://github.com/NixOS/nixpkgs/commit/e06082eda06ee586de17e0a060e8cd0eddd20c69

Google Chrome: Broken since M98(?).

This issue lacks information but I decided to open it anyway to track those regressions. Any help would be welcome.

cc @Synthetica9 (https://github.com/NixOS/nixpkgs/issues/156352) cc @travisbhartwell @manveru @prusnak (Electron maintainers)

edrex commented 2 years ago

With vscode and Obsidian, I'm not seeing a coredump, just a hang at startup. Same cause?

NANASHI0X74 commented 2 years ago

I took the venture into experimental territory today with setting NIXOS_OZONE_WL and ran into this issue. Can I help? I guess each affected package must be updated to fix this, does anything need to be done for electron itself additionally? Also, would it make any sense to install slack via snap instead of the .deb package?

prusnak commented 2 years ago

Electron 17.3.1 with Wayland fix has been released (contains this fix https://github.com/electron/electron/pull/33499) and nixpkgs has been updated in https://github.com/NixOS/nixpkgs/pull/166587

Can someone please check whether this update has fixed the issue?

NANASHI0X74 commented 2 years ago

not sure if this is the bast way to do this, but I just updated from the current unstable to master with nix flake lock --override-input nixpkgs github:NixOS/nixpkgs/master --update-input nixpkgs (as unstable is apparenty currently blocked :/ ) The rebuild takes a while now 😅

edrex commented 2 years ago

@prusnak which apps use the nixpkgs electron17? VSCode is on 17 but it bundles electron (should really fix that). Obsidian should be on 17 but is currently on 16. Will probably bump it and test if someone doesn't first.

prusnak commented 2 years ago

which apps use the nixpkgs electron17?

Grep pkgs/top-level/all-packages.nix for electron_17:

NANASHI0X74 commented 2 years ago

not sure if this is the bast way to do this, but I just updated from the current unstable to master with nix flake lock --override-input nixpkgs github:NixOS/nixpkgs/master --update-input nixpkgs (as unstable is apparenty currently blocked :/ ) The rebuild takes a while now sweat_smile

can confirm this works with element-desktop and slack :D nice 👍

ivankovnatsky commented 2 years ago

For me slack still crashes (as it's not using electron17 yet i guess, not sure how it runs on your side), I see that that PR already landed in nixos-unstable https://nixpk.gs/pr-tracker.html?pr=166587, which I use.

element-desktop launches and runs fine.

NANASHI0X74 commented 2 years ago

slack's actually a bit flaky I noticed, sometimes it works and sometimes it doesn't display anything (but seems to load the window title at least) no idea what the problem is there

wmertens commented 2 years ago

FYI this is a known issue and the workaround is to run the affected program multiple times, eventually it will work. I do believe it's fixed in recent Electrons but I don't have pointers offhand.

edrex commented 2 years ago

Tested with obsidian :+1:

I think this issue can be closed? It's honestly pretty nebulous as written (the chrome breakage was fixed months ago)

edrex commented 2 years ago

The only additional change would be to backport the fix to earlier electrons, but probably better to get those packages which depend on old electron upgraded.

edrex commented 2 years ago

VSCode 1.66 was released with electron 17.2.0. The insider (nightly) build has the needed 17.3.1, and indeed works under wayland (with some jank):

    vscode-insider = (prev.vscode.override {isInsiders = true;}).overrideAttrs (oldAttrs: rec {
      src = (builtins.fetchTarball {
        url = "https://update.code.visualstudio.com/latest/linux-x64/insider";
        sha256 = "048aizmk3513z1y6rxlfg87k7b74hilh6kydvgpz9lhrj1gymirf";
      });
      version = "latest";
    });

We will have to wait for the April stable release.

wmertens commented 2 years ago

I wonder if we can't patch the official release with our own electron?

edrex commented 2 years ago

@wmertens wayland isn't stable in the insider build. I think users should keep running under xwayland for now, and hopefully wayland support will be stabilized upstream before the 1.67 release.

xaverdh commented 2 years ago

Not sure of this is related, but recently I get [5036:0510/101840.222112:FATAL:platform_selection.cc(45)] Invalid ozone platform: wayland}} fish: Job 1, 'signal-desktop' terminated by signal SIGTRAP (Trace or breakpoint trap) when trying to start signal-desktop. I am on xmonad (Xorg).

xaverdh commented 2 years ago

ah never mind I think this is due to https://github.com/NixOS/nixpkgs/pull/164163..

edrex commented 2 years ago

Suggest we close this (@primeos) and open specific issues for each problem to get things in good shape (and we can still reference this one to act as an index).

The VSCode instability I mentioned is tracked upstream in https://github.com/microsoft/vscode/issues/148507.

Obsidian is running very well for me native, however it needs a wrapper patch to use wayland by default or respect NIXOS_OZONE_WL=1. For now launch with obsidian --ozone-platform=wayland.

primeos commented 2 years ago

Feel free to split this issue up and(/or) close it. I don't use Electron apps or Google Chrome (anymore) and IIRC I only opened this issue to centralize the discussion and raise awareness. AFAIK our packaging is lacking and we'd need a general abstraction for Electron apps (there are just so many and they're currently packaged quite inconsistently). Ideally that abstraction could also be used for Google Chrome (where changes are usually required first - especially since we package the beta and dev channels as well).

wmertens commented 2 years ago

@primeos do you happen to have some ideas for such an abstraction?

I know many apps are just elf-patched versions of the distributed electron binaries, but I don't know enough about electron (yet). Do you think we could scrape the custom code out of those packages and pair it to our own build of (the correct version of) electron?

primeos commented 2 years ago

I was thinking of something like mkElectronDerivation (for the lack of a better name) that mainly provides the correct runtime dependencies and wrapper options by default (it might also require an attribute like majorElectronVersion in case there are breaking changes required to support newer Electron versions but ideally this could be avoided as it's probably annoying for packagers / update scripts). That way all Electron apps should behave the same (apart from the Electron version, etc.) and not miss any optional dependencies (e.g., for Wayland support).

Do you think we could scrape the custom code out of those packages and pair it to our own build of (the correct version of) electron?

That would be nice and IIRC it's supposed to be possible but I guess it would be the next step after having a basic abstraction. It could provide lots of advantages (security updates, bug fixes, etc.) but of course also drawbacks like incompatibilities.

wmertens commented 2 years ago

Ok, that makes sense. I'm sure there's lots of incompatibilities between major versions, or vscode wouldn't have waited so long to upgrade.

I'll have a look but most likely it won't be me that gets this done :)

FlorianFranzen commented 2 weeks ago

@primeos Does this still need a fix or can this issue be closed?