VHSgunzo / sharun

Run dynamically linked ELF binaries everywhere
MIT License
16 stars 2 forks source link

Handle webkit2gtk-4.0 #2

Open probonopd opened 15 hours ago

probonopd commented 15 hours ago

webkit2gtk-4.0 needs some extra handling as described in https://github.com/tauri-apps/tauri/pull/2940.

https://github.com/probonopd/PrusaSlicer/blob/efe3df7c9a9a3bd8c2b7bdfa3ec6bb31bb67ab41/.github/workflows/build.yml#L100

is apparently not the way to do it, as it did not work for me.

xplshn commented 15 hours ago

@probonopd sharun simply executes the ld.so with --library-path using the libraries on ./shared, it doesn't do anything deploy-like other than setting a few common env variables if certain directories are found in the AppDir.

I suppose this is something that you think should be added to lib4bin? But even then, shouldn't it work by default with the strace mode?

probonopd commented 15 hours ago

Right, probably needs to be handled in lib4bin, which is also mentioned here. I'm still new to all of this ;-)

Samueru-sama commented 12 hours ago

Tauri does this to the libs:

#binary patch absolute paths in libwebkit files
find "$APPDIR"/usr/lib* -name 'libwebkit*' -exec sed -i -e "s|/usr|././|g" '{}' \;

But why? Also doesn't this mean that they need to change the working directory to the AppDir?

What I mentioned here would be a different problem because we are also shipping the dynamic linker, maybe that tauri patch isn't needed and just the binaries need to be wrapped with sharun hopefully.

probonopd commented 12 hours ago

I assume that libwebkit wants to launch the webkit helper binaries from a compiled-in path in /usr. So they are patching that to ././ and probably cd to AppDir/usr prior to executing the main application binary. As a result, libwebkit might launch the webkit helper binaries from inside the AppDir. Quite a hack but I have done similar things against compiled-in absolute paths in the past.

probonopd commented 8 hours ago
user@DESKTOP-4U17RT8:/mnt/c/Users/User/Downloads/squashfs-root$ ./AppRun

(prusa-slicer:143): Gtk-CRITICAL **: 08:37:06.918: gtk_window_resize: assertion 'width > 0' failed
[2024-11-22 08:37:07.175705] [0x00007faf8b8fb7c0] [error]   UserAccount: Failed to read token - no datafile found.
[2024-11-22 08:37:09.009464] [0x00007faf3cff9640] [error]   DBus Connection Error: /usr/bin/dbus-launch terminated abnormally without any error message
[2024-11-22 08:37:09.009503] [0x00007faf3cff9640] [error]   Dbus Messages listening terminating.
08:37:11 AM: Debug: window wxTreeCtrl@0x55557fed9ea0 ("treeCtrl") lost focus even though it didn't have it
08:37:11 AM: Debug: window wxTreeCtrl@0x55557fed9ea0 ("treeCtrl") lost focus even though it didn't have it

** (prusa-slicer:143): ERROR **: 08:37:13.934: Unable to spawn a new child process: Failed to spawn child process “/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/WebKitNetworkProcess” (No such file or directory)
Trace/breakpoint trap (core dumped)

It is looking for WebKitNetworkProcess at a compiled-in absolute path.

Maybe we need to resort to ././ patching if we find no other way?

Samueru-sama commented 8 hours ago

Maybe we need to resort to ././ patching if we find no other way?

Most likely, also sharun the binaries in the webkit2gtk-4.0 dir which is basically just moving the binaries to the ./shared/bin dir and putting a relative symlink in their original place and name that points to sharun.

You can also set SHARUN_WORKING_DIR=${SHARUN_DIR} on the .env file to make sharun cd into the AppDir when running (it is the equivalent of cd "$HERE" on the typical shell AppRun) if you go with the patching route.