NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.01k stars 14.02k forks source link

Evolution, epiphany: Webkitgtk bubblewrapper crashes when LD_LIBRARY path points into /run/current-system/** (the case on a pipewire system with jack emulation) #110468

Closed Emantor closed 3 years ago

Emantor commented 3 years ago

Describe the bug Mails are not displayed within evolution. I'm running sway, so evolution is run under the wayland backend. It's also broken when forcing evolution to use X11.

To Reproduce Steps to reproduce the behavior:

  1. start evolution
  2. Try to open a mail by double clicking
  3. New window for the mail displays:
    
    Something has gone wrong when displaying the message

A WebKitWebProcess crashed when displaying the message. You can try again by moving to another message and back. If the issue persists, please file a bug report in GNOME Gitlab.

**Expected behavior**
Being able to read the mail instead of the error message.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
The only change touching webkitgtk was #96140.

**Notify maintainers**
@NixOS/gnome 

**Metadata**
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
Emantor commented 3 years ago

Epiphany is also broken.

jtojnar commented 3 years ago

cc @matthewbauer

matthewbauer commented 3 years ago

I think this is from not being able to find the libwpe-fdo plugin. You shouldn't need it on X11, I think, but on wayland it needs to find the plugin somewhere. The situation is annoying (https://github.com/WebPlatformForEmbedded/libwpe/issues/59), but for now we can just hardcode it to avoid the issue (albeit breaking the ability to add more plugin). Should have a fix available soon.

matthewbauer commented 3 years ago

I've opened https://github.com/NixOS/nixpkgs/pull/110738 to revert. Can't quite figure out what needs to change - WPE_RENDERER is enabled on other distros without issue, so there's got to be some way to get it working.

worldofpeace commented 3 years ago

It appears that the plugin loader in its current state could not work on nixos, as most plugin system unfortunately. The two PRs created https://github.com/Igalia/WPEBackend-fdo/pull/99/files https://github.com/WebPlatformForEmbedded/libwpe/pull/64/files changes how backend implementations are loaded by searching in a directory WPE_BACKENDS_DIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/wpe-${WPE_API_VERSION}\" which will be compiled in. Not even that will work for as us everything is installed into separate prefixes. They could however, to support us, include an environment variable to recurse for plugins.

So this requires creating a wpe-with-plugins just to use the fdo plugin for webkitgtk. The code that changes the plugin loading isn't merged yet so we could suggest a solution to support our usecase or PR against the PR. Or just roll our own patches.

worldofpeace commented 3 years ago

... realizes these aren't executable

worldofpeace commented 3 years ago

So this would then require :grin: changing the loader so that wpe_loader_init can accept an absolute path to a plugin. And we'd have to perform code substitution on the users of the function to load the intended plugin from an absolute path.

diff --git a/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp b/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
index a380a25fa4b..d96d23bce2e 100644
--- a/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
+++ b/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
@@ -114,7 +114,7 @@ void WebProcessPool::platformInitializeWebProcess(const WebProcessProxy& process
 #if PLATFORM(WAYLAND)
     if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::Wayland) {
 #if USE(WPE_RENDERER)
-        wpe_loader_init("libWPEBackend-fdo-1.0.so");
+        wpe_loader_init("@libwpe_fdo@libWPEBackend-fdo-1.0.so");
         if (wpe_fdo_initialize_for_egl_display(WebCore::PlatformDisplay::sharedDisplay().eglDisplay())) {
             parameters.hostClientFileDescriptor = wpe_renderer_host_create_client();
             parameters.implementationLibraryName = FileSystem::fileSystemRepresentation(wpe_loader_get_loaded_implementation_library_name());
diff --git a/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp b/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
index a380a25fa4b..d96d23bce2e 100644
--- a/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
+++ b/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
@@ -114,7 +114,7 @@ void WebProcessPool::platformInitializeWebProcess(const WebProcessProxy& process
 #if PLATFORM(WAYLAND)
     if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::Wayland) {
 #if USE(WPE_RENDERER)
-        wpe_loader_init("libWPEBackend-fdo-1.0.so");
+        wpe_loader_init("/nix/store/dp94mlfkz0yxj53yk4bhcdxkcbax764q-wpebackend-fdo-1.7.1/lib/libWPEBackend-fdo-1.0.so");
         if (wpe_fdo_initialize_for_egl_display(WebCore::PlatformDisplay::sharedDisplay().eglDisplay())) {
             parameters.hostClientFileDescriptor = wpe_renderer_host_create_client();
             parameters.implementationLibraryName = FileSystem::fileSystemRepresentation(wpe_loader_get_loaded_implementation_library_name());
worldofpeace commented 3 years ago

Reasonably, I think wpe could support loading a plugin relatively and absolutely. It shouldn't be a very intrusive change, although we have to do this madness to actually use it.

Emantor commented 3 years ago

I have now switched to nixos-unstable-small to test the revert however evolution and epiphany are still broken. Could this be due to my local setup? Can others reproduce this?

Emantor commented 3 years ago

This is due to me using pipewire instead of pulseaudio, using pipewire outputs

bwrap: Can't mkdir parents for /run/current-system/sw/lib/pipewire: No such file or directory

when starting epiphany or evolution.

Emantor commented 3 years ago

The nixos pipewire module sets LD_LIBRARY_PATH to /run/current-system/sw/lib/pipewire if cfg.jack.enable is enabled, this is parsed by the webkitgtk bubblewrap launcher, which tries to bind this path. However this bind fails, crashes the bubblewrapper and webkitgtk fails to start. Unsetting LD_LIBRARY_PATH lets me use evolution with pipewire only.

gshipunov commented 3 years ago

Can others reproduce this?

Run into the same issue, nixos-unstable 536fe36e23ab0fc8b7f35c24603422eee9fc17a2. The peculiarity is the fact that I'm not explicitly enabling pipewire and/or jack.

pactl info:

Server String: /run/user/1000/pulse/native
Library Protocol Version: 34
Server Protocol Version: 34
Is Local: yes
Client Index: 4
Tile Size: 65472
User Name: grigory
Host Name: dishwasher
Server Name: pulseaudio
Server Version: 14.2-rebootstrapped

When running evolution (or epiphany) from the terminal bwrap suggests enabling non-privileged user namespaces: $ evolution:

bwrap: No permissions to creating new namespace, likely because the kernel does not allow non-privileged user namespaces. On e.g. debian this can be enabled with 'sysctl kernel.unprivileged_userns_clone=1'.

Doing exactly as it suggests fixes evolution.

If anyone has any idea how to debug that, feel free to provide instructions

hmenke commented 3 years ago

Just updated from nixos-20.09 to nixos-21.05 with services.pipewire.jack.enable = true and get the same error.

nixos-discourse commented 3 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/headphone-volume-resets-itself-to-100/13866/2

mm-- commented 3 years ago

From looking at what @Emantor posted, it seems like bubblewrap has some issues with bind mounting symlinks. WebKitGTK should probably try to canonicalize source paths before bind mounting them on a destination.

In the meantime, a workaround for people that want to use PipeWire+JACK and WebKitGTK at the same time is to set the LD_LIBRARY_PATH to the absolute path in the nix store instead of /run/current-system/sw/lib/pipewire. Here's how you can do this in your config:

{ config, pkgs, lib, ... }:

{
  environment.sessionVariables.LD_LIBRARY_PATH = lib.mkForce "${config.services.pipewire.package.jack}/lib";
  services.pipewire = {
    enable = true;
    # ...
    jack.enable = true;
    # ...
  };
}
fufexan commented 3 years ago

I have a problem caused by the same issue with pipewire, where I can't add some accounts to Gnome, including Google, Facebook, Microsoft.

fufexan commented 3 years ago

Using @Artturin's patch fixed the account login screen not appearing and epiphany instantly crashing.

However, now I have another issue. Starting either epiphany/Gnome account login works fine but the window is blank.

Captură de ecran de la 2021-09-02 18-32-38

Oddly enough, https://html.duckduckgo.com works

This is a relevant issue I found, but it's from 2 years ago https://gitlab.gnome.org/GNOME/epiphany/-/issues/570

EDIT: prepending WEBKIT_DISABLE_COMPOSITING_MODE=1 fixed it.

nixos-discourse commented 3 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/sound-only-works-while-pavucontrol-is-open/15280/2

danwdart commented 3 months ago

This being done does that mean that we no longer need to use the workaround?

jtojnar commented 3 months ago

The workaround from https://github.com/NixOS/nixpkgs/issues/110468#issuecomment-874989177 was applied to the NixOS module in https://github.com/NixOS/nixpkgs/pull/136475.

But we should not need it since we no longer have webkitgtk use fdo backend either.