ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.35k stars 238 forks source link

Wine's Wayland driver does not load #1581

Closed strobo5 closed 1 week ago

strobo5 commented 2 weeks ago

I'm trying to run wine (wine-9.9) on aarch64, in a Ubuntu 24.04 userspace within Docker since the main OS uses muslibc. Wine was compiled manually on a Ubuntu 24.04 x86_64 machine with Wayland and syswow64 support:

./configure --enable-archs=i386,x86_64 --enable-win64 --with-wayland=yes

I enable Wayland like this:

wine reg.exe add HKCU\\Software\\Wine\\Drivers /v Graphics /d wayland,x11

I can start winecfg, it works by falling back to X11, but when force it to use Wayland by having an empty DISPLAY environment variable it fails to start.

I created a log with WAYLAND_DEBUG=1 WINEDEBUG=+loaddll,+module,+imports,+waylanddrv,+x11drv and attached the part of it where winewayland.drv is being loaded. Unfortunately I don't have an understanding of what is happening here under the hood. Should I not see a line like this somewhere?

Using native(wrapped) libwayland-client.so.0

wine-9.9_winecfg_WINEDEBUG_loaddll_module_imports_waylanddrv.log

Some notes:

Attaching more uncut gzipped logs because it's free, but they are large: winecfg_WINEDEBUG_waylanddrv_loaddll_BOX64_LOG_3.log.gz winecfg_WINEDEBUG_waylanddrv_loaddll_module_imports.log.gz winecfg_WINEDEBUG_waylanddrv_loaddll_module_imports_relay.log.gz winecfg_WINEDEBUG_waylanddrv_loaddll_relay.log.gz

ptitSeb commented 2 weeks ago

I only tested Wayland with this version of wine-wayland: https://github.com/varmd/wine-wayland (the 9.3.4 from the releases). I'm not sure wayland from upstream is working fine.

the same "hello-wayland", but compiled on x86_64 and run through box64, crashes with a SIGBUS exception (another bug?)

Yes, probably a missing wrapping. Check message like BOX64: Error, Wayland-client, add_listener to XXXX unknown, I need the XXXX to add it to box64. This program use listener that are not wrapped yet certainly.

ptitSeb commented 2 weeks ago

I created a log with WAYLAND_DEBUG=1 WINEDEBUG=+loaddll,+module,+imports,+waylanddrv,+x11drv and attached the part of it where winewayland.drv is being loaded. Unfortunately I don't have an understanding of what is happening here under the hood. Should I not see a line like this somewhere?

Using native(wrapped) libwayland-client.so.0

Yeah, it should. I don't see anything wayland being loaded indeed. try the wine-wayland I linked instead for now.

strobo5 commented 2 weeks ago

Yeah, it should. I don't see anything wayland being loaded indeed. try the wine-wayland I linked instead for now.

Hmm interesting, I got that version of wine, did wine wineboot with a fresh prefix and then WINEDEBUG=+waylanddrv,+loaddll wine regedit. It fails like this (some lines removed for brevity):

00d0:trace:loaddll:build_module Loaded L"C:\\windows\\system32\\winewayland.drv" at 00006FFFFE880000: builtin
00d0:trace:waylanddrv:xinerama_init Virtual rect 1920 1080 (0,0)-(1920,1080) 
00d0:trace:waylanddrv:WAYLANDDRV_UpdateDisplayDevices via desktop 1920 1080
[..]
00d4:trace:waylanddrv:WAYLANDDRV_DestroyWindow Destroying 0x10030 L"__wine_clipboard_manager" Window title 0 / L"" 
00d4:trace:waylanddrv:WAYLANDDRV_DestroyWindow Destroying window 1 
[..]
00d0:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80004002
00d0:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, hr 0x80004002
00d0:err:ole:apartment_get_local_server_stream Failed: 0x80004002
00c8:trace:loaddll:build_module Loaded L"c:\\windows\\system32\\winewayland.drv" at 00006FFFFE880000: builtin
Using emulated /home/michael/wine/lib/wine/x86_64-unix/winewayland.so
Using native(wrapped) libwayland-client.so.0
Using native(wrapped) libwayland-cursor.so.0
Error: Global Symbol wl_buffer_interface not found, cannot apply R_X86_64_GLOB_DAT @0x7fff03013f60 ((nil)) in /home/michael/wine/lib/wine/x86_64-unix/winewayland.so
00c8:trace:waylanddrv:xinerama_init Virtual rect 1920 1080 (0,0)-(1920,1080) 
00c8:trace:waylanddrv:WAYLANDDRV_UpdateDisplayDevices via desktop 1920 1080
[..]
00c8:trace:waylanddrv:WAYLANDDRV_WindowPosChanging Changing 0x10070 L"RegEdit_RegEdit" 
00c8:trace:waylanddrv:WAYLANDDRV_WindowPosChanging Changing 0x10070 L"RegEdit_RegEdit" Window title 0 / L"" (0,0)-(0,0) rect 
00c8:trace:waylanddrv:WAYLANDDRV_WindowPosChanging Changing 0x10070 L"RegEdit_RegEdit" 
00c8:trace:waylanddrv:WAYLANDDRV_WindowPosChanging Changing 0x10070 L"RegEdit_RegEdit" Window title 15 / L"Registry Editor" (0,0)-(1440,810) rect 
[..]
00c8:trace:waylanddrv:WAYLANDDRV_WindowPosChanging Changing 0x10070 L"RegEdit_RegEdit" 
00c8:trace:waylanddrv:WAYLANDDRV_WindowPosChanging Changing 0x10070 L"RegEdit_RegEdit" Window title 15 / L"Registry Editor" (0,0)-(1440,810) rect 

followed by a bunch of SIGBUS exceptions. But it loads libwayland-client \o/

strobo5 commented 2 weeks ago

Yes, probably a missing wrapping. Check message like BOX64: Error, Wayland-client, add_listener to XXXX unknown, I need the XXXX to add it to box64. This program use listener that are not wrapped yet certainly.

I can't find an error like this :o I attached a log with BOX64_DEBUG=3, maybe it can shed some light hello-wayland_BOX64_LOG_3.log.gz

ptitSeb commented 2 weeks ago

Error: Global Symbol wl_buffer_interface not found, cannot apply R_X86_64_GLOB_DAT @0x7fff03013f60 ((nil)) in /home/michael/wine/lib/wine/x86_64-unix/winewayland.so

This line is the issue. But this is added to box64 already. Are you sure you are using latest version of box64? What gives you box64 --version ?

strobo5 commented 2 weeks ago

This line is the issue. But this is added to box64 already. Are you sure you are using latest version of box64? What gives you box64 --version ?

Welllll now I realized that just yesterday you pushed changes to the Wayland wrappings :D that was a coincidence, my build of box64 is from about a month ago, I kept checking for related commits but not yesterday, of course! Let me try again with a fresh build once I'm back home

strobo5 commented 2 weeks ago

hello-wayland works now! I built box64 v0.2.8-213-ga3d09e95. Screenshot from 2024-06-14 00-31-32

The wine-9.3 build from above also seems to work, but the window is invisible. I do see Wayland things happening with WAYLAND_DEBUG=1. This could be an issue with my system - the Nextcloud client is hiding itself in a similar way.

My own build of wine-9.9 seems to behave the same way as before, though. When winewayland.drv is loaded there is this message in the log: 0048:warn:module:process_attach Initialization of L"winewayland.drv" failed. The spam around this in the log file seems to be the same as in the gzipped logs in my initial post.

strobo5 commented 1 week ago

I went into a GDB adventure to find some clues. There are missing wrappings for what box64 finds in the RELA PLT section of "winewayland.so", so RelocateElfRELA() fails. Here they are in order of occurrence in that table:

wl_list_init wl_array_release wl_list_remove wl_array_add wl_list_insert rxkb_layout_next@V_1.0.0 wl_array_init rxkb_context_parse_default_ruleset@V_1.0.0

I can see that these are new since the linked wine-9.3 by comparing the output of readelf -rW lib/wine/x86_64-unix/winewayland.so | awk '/R_X86_64_JUMP_SLOT/{print $5}' | sort -fi).

I think there should have been more debugging output with BOX64_LOG=2 that would have indicated this - did this fail to appear because it is some child process (box64 wine explorer.exe) that eventually loads this library, not the initial box64 wine regedit?

Anyway, I tried my luck adding the wrappings, but all I get is a SIGILL somewhere around where winewayland.so is loaded. Hm!

strobo5 commented 1 week ago

fixed by #1599

I'm still puzzled why BOX64_LOG=2 did not seem to work in my case, but that's for another issue, and another day.