netbrain / zwift

Easily zwift on linux
The Unlicense
295 stars 32 forks source link

Container crashes on wayland. Works on X: err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded. #88

Closed NaevaTheCat closed 6 months ago

NaevaTheCat commented 7 months ago

Describe the bug Running the container closes almost immediately, checking the journal I see:

Apr 11 10:34:04 bark zwift[25964]: 01a4:err:ole:CoGetContextToken apartment not initialised
Apr 11 10:34:04 bark zwift[25964]: 0184:err:combase:RoGetActivationFactory Failed to find library for L"Windows.Foundation.Diagnostics.AsyncCausalityTracer"
Apr 11 10:34:05 bark zwift[25964]: 0184:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
Apr 11 10:34:05 bark zwift[25964]: 0184:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
Apr 11 10:34:05 bark zwift[25964]: + wine start /exec /bin/runfromprocess-rs.exe 384 ZwiftApp.exe '--token={"access_token":"<redacted>","expires_in":21600,"refresh_expires_in":691200,"refresh_token":"<redacted>","scope":"openid"}'
Apr 11 10:34:05 bark zwift[25964]: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: HRESULT(0x80070057), message: "Invalid parameter." }', src/main.rs:38:73
Apr 11 10:34:05 bark zwift[25964]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Apr 11 10:34:05 bark zwift[25964]: 01e0:err:seh:NtRaiseException Unhandled exception code c0000409 flags 1 addr 0x1400347f6

stdout is:

+ IMAGE=docker.io/netbrain/zwift
+ VERSION=latest
+ [[ ! -n '' ]]
++ command -v podman
+ [[ -x /usr/bin/podman ]]
+ CONTAINER_TOOL=podman
+ [[ ! -n '' ]]
+ podman pull docker.io/netbrain/zwift:latest
Trying to pull docker.io/netbrain/zwift:latest...
Getting image source signatures
Copying blob c12bfc3fd135 skipped: already exists
<SNIP>
bb153ec22d63b7bd628ba5b929b5bab98946ca8b121020fc98e59f3bfded184b
+ [[ -f /proc/driver/nvidia/version ]]
+ VGA_DEVICE_FLAG='--device /dev/dri:/dev/dri'
+++ '[' podman = podman ']'
+++ echo --userns=keep-id
++ podman run -d --rm --privileged -e DISPLAY=:1 -v /tmp/.X11-unix:/tmp/.X11-unix -v /run/user/1000/pulse:/run/user/1000/pulse -v zwift-naeva:/home/user/Zwift --userns=keep-id --device /dev/dri:/dev/dri docker.io/netbrain/zwift:latest
+ CONTAINER=ab12285132782d872399f8865e86713f0bfd472c2c8426e8a964dd5be2772040
+ [[ -z wayland-0 ]]

Without authentication I just see this:

Apr 11 08:41:00 bark zwift[8761]: 01c0:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
Apr 11 08:41:00 bark zwift[8761]: 01c0:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
Apr 11 08:41:01 bark zwift[8761]: + pgrep -f ZwiftApp.exe
Apr 11 08:41:01 bark zwift[8761]: Killing uneccesary applications

So I think that's likely the salient stuff.

To Reproduce Load plasma on wayland, run /usr/local/bin/zwift

Additional context If I load plasma on X and run it (after installing xhost) it works fine. It seems to be some wayland problem? This is the first time I've used wayland/a desktop environment in more than a decade so I am pretty clueless at what to troubleshoot.

System information:

OS: Arch Linux x86_64 
Host: 20QGS1DB00 ThinkPad X1 Yoga 4th 
Kernel: 6.8.4-arch1-1 
Uptime: 12 hours, 54 mins 
Packages: 1503 (pacman) 
Shell: bash 5.2.26 
Resolution: 1920x1080 
DE: Plasma 6.0.3 
WM: kwin 
Theme: [Plasma], Breeze-Dark [GTK2], Breeze [GTK3] 
Icons: [Plasma], breeze-dark [GTK2/3] 
Terminal: konsole 
Terminal Font: MesloLGS NF 14 
CPU: Intel i5-8365U (8) @ 4.100GHz 
netbrain commented 7 months ago

What graphics card are you using?

Most likely you are missing the correct graphics driver in the container itself. Im guessing this works on zwift version 1.60.0? i.e

VERSION=1.60.0 zwift

Could you also try to see if glxgears would spin up in the container?

This will run the container interactively

podman run -it --rm --privileged -e DISPLAY=:1 -v /tmp/.X11-unix:/tmp/.X11-unix -v /run/user/1000/pulse:/run/user/1000/pulse -v zwift-naeva:/home/user/Zwift --userns=keep-id --device /dev/dri:/dev/dri  --entrypoint=bash docker.io/netbrain/zwift:latest
glxgears
NaevaTheCat commented 7 months ago

Apparently I am a bad user who fails at copy paste.

GPU: GPU: Intel WhiskeyLake-U GT2 [UHD Graphics 620]


Downloading zwift 1.60.0 and running (I had not used any previous versions) it I get:

Apr 11 17:52:20 bark zwift[51353]: 0138:err:combase:RoGetActivationFactory Failed to find library for L"Windows.Foundation.Diagnostics.AsyncCausalityTracer"
Apr 11 17:52:21 bark zwift[51353]: 0138:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
Apr 11 17:52:21 bark zwift[51353]: 0138:err:winediag:nodrv_CreateWindow L"Make sure that your X server is running and that $DISPLAY is set correctly."

which seems like the same thing.

Running those 2 commands I get:

user@4287b882a301:~$ glxgears
bash: glxgears: command not found

glxgears works fine outside the container though, if that's relevant /shrug

netbrain commented 7 months ago

sorry, please do a sudo apt update && sudo apt install mesa-utils before trying to run glxgears

also show me the output of glxinfo

netbrain commented 7 months ago

Ah, see now that you actually have it working in X? but not wayland? correct? In that case i'ts probably something with how podman / wayland interacts.

But, if you can get a container with glxgears to run under wayland, then zwift should work aswell. A good starting point would be this:

https://github.com/netbrain/zwift/issues/80#issuecomment-2039116156

And then try to tweak podman flags in order to allow the container to use your graphics device.

sebstrand commented 7 months ago

I had a similar issue (also on Arch Linux with Wayland) and removing the if-statement around xhost in zwift.sh (so that it runs even if Wayland is in use) fixed it for me, if I remember correctly.

NaevaTheCat commented 7 months ago

Thanks for your patience with this.

Yes, it does work if I log in to an X session vs a wayland session.

Installing mesa-utils and running glxgears I get:

user@a6b42aa4eff8:~$ glxinfo
Authorization required, but no authorization protocol specified

Error: unable to open display :1

Baffling, since I'm not running X

However if I do xhost + and then run the container it works.

So it looks like stuff is being forced through xhost or something? I'm not entirely sure.

As a result doing what sebstrand says works.

Baffling! Idk if you want to leave this open to fix in a future release or consider it closed, it's probably worth documenting though?

netbrain commented 7 months ago

Im running wayland myself, but i don't need to do xhost in order to get zwift running. So not sure why you have to. guess it comes down to how wayland is configured? or myabe Xwayland.

Another alternative thing you could try is to use the experimental wayland feature in wine (see WINE_EXPERIMENTAL_WAYLAND in README). but in that case i think you need to forward other environment variables aswell and set DISPLAY to an empty string. @quietvoid might now a thing or two about this as i'm pretty sure he has tested out wine with wayland support.

quietvoid commented 7 months ago

I have not tested the current image but I'll try to later today or on the weekend.

The Wine Wayland driver can't be used for Zwift until version 9.4 (OpenGL basic support), so if the image is actually on 9.0 it's not possible to use it. It would be a different error though.

So here it just seems like a misconfiguration that makes it not find the X display.

quietvoid commented 7 months ago

I just tested the latest netbrain/zwift image and it works fine for me. Might be a podman specific issue.

cmuench commented 7 months ago

I just updated to latest fedora (40) which will be released tomorrow. Fedora 40 comes with Wayland only. I have the same issues as described above. It's only starting with xhost + before docker run.

sHedC commented 7 months ago

Wayland on Fedora 40 works for me without the xhost + using 1.62.0

Using 1.63.0 with Podman now gives me a permissions error on groupmod -o -g user, this gives me the same issue on Fedora 39. The latest update you can't run groupmod or usermod using rootless podman by the looks of it.

sHedC commented 7 months ago

I just updated to latest fedora (40) which will be released tomorrow. Fedora 40 comes with Wayland only. I have the same issues as described above. It's only starting with xhost + before docker run.

Just found a post on this one, someone said they put this in their bash script on startup

xhost +si:localuser:$USER

This is what made my zwift work on wayland fedora 40 without modifying the zwift script maybe this can be added to the zwift script?

This is for 1.62.0, still have an issue that two new commands in 1.63.0 don't work with podman rootless.

sHedC commented 7 months ago

This really bugged me, for the latest podman is working fine but not displaying under wayland. Under X works but requires running xhost + or xhost +si:localuser:$USER first.

In short, under Fedora 40 Wayland this worked for me, still needed xhost +

Doing this worked

podman run -it --rm --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /run/user/1000/pulse:/run/user/1000/pulse -v zwift-naeva:/home/user/Zwift --userns=keep-id --device /dev/dri:/dev/dri  --entrypoint=bash docker.io/netbrain/zwift:latest

wine notepad

But doing this, which is how the latest runs, gave me more information (removing the --userns=keep-id)

podman run -it --rm --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /run/user/1000/pulse:/run/user/1000/pulse -v zwift-naeva:/home/user/Zwift --device /dev/dri:/dev/dri  --entrypoint=bash docker.io/netbrain/zwift:latest

wine notepad
gosu user:user wine notepad

The first works the second does not.

Further investigation when you gosu or su or sudo to a user you loose the access to the X11 server. There are some things online about this but I couldn't get any working.

In the end I found a post that said just put --net host and it works, so the solution to change NETWORKING=host worked for me under wayland.

joekm commented 7 months ago

Still trying to figure out how to get the container to see my graphics card (AMD). I can't really install anything within that container because the user podman creates for me does not have sudo permission and, trying to run sudo --user=[ME] doesn't seem to work either.

It's running, but it appears to be running off my CPU and not the GPU. This is true in both X and Wayland.

sHedC commented 7 months ago

Still trying to figure out how to get the container to see my graphics card (AMD). I can't really install anything within that container because the user podman creates for me does not have sudo permission and, trying to run sudo --user=[ME] doesn't seem to work either.

It's running, but it appears to be running off my CPU and not the GPU. This is true in both X and Wayland.

Assuming your CPU is an intel and your primary display is the intel iGPU then not sure how you can get it to pick up the Radeon, the app uses /dev/dri for Intel/ AMD and it is picking up the first capable card.

You could try passing DRI_PRIME=1 as an environment variable, adding -e DRI_PRIME=1 to the zwift startup.

joekm commented 7 months ago

My setup is all AMD. Ryzen 7 5800X CPU and Radeon RX6700XT graphics. Motherboard has no onboard graphics.

I also run openRGB setup to give me color scale indications of CPU, GPU, and memory temperature. It works pretty well in giving me an indication as to what's being loaded. When I run Zwift, the CPU fan color shows it's warming up, but the window in front of the graphics card is staying blue, indicating it's not really becoming active.

sHedC commented 7 months ago

similar to mine mine is an AMD 5700G with RX6700XT, I am running in proxmox so have setup just with the RX using Fedora 40 under Wayland. (currently accessing over RDP can try without during the week direct with the RX.

Install zwift xhost + start radeontop zwift

in my case radeontop shows activity once zwift started.

ls -la /dev/dri shows render128 as crw, rw, rw

Inside the container, starting as root:

podman run -it --rm --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /run/user/1000/pulse:/run/user/1000/pulse -v zwift-naeva:/home/user/Zwift --device /dev/dri:/dev/dri  --entrypoint=bash docker.io/netbrain/zwift:latest

apt update
apt install mesa-utils
glxgears -info

Shows that the RX is being used and RadeonTop shows activity ls -la /dev/dir shows render128 as crw,rw,rw

joekm commented 7 months ago

Ok, radeontop does confirm the graphics card is active. I should have thought to run that to cross-check OpenRGB.

Curious though, the argb CPU cooler fan is changing color to show the CPU is getting warm, but the window in front of the graphics card stays blue. Just launched Borderlands 3 just to verify it's working and, the window changed color as expected when the game's graphic engine came online.

It may be as simple as Zwift just doesn't load my graphics card that much. Next time I run it, I'll try cranking up the graphics settings and see if that doesn't wake it up a bit.

That being said, it appears to be working after all, and I don't even seem to need xhost +.

UPDATE: Ok, "Jurrasic Coast" was just enough graphics load to make the temperature monitor color just start to transition from blue to green. No doubt it's working correctly now. It just doesn't load my card that much.

sHedC commented 6 months ago

Hi, can you re-try. Re-install the latest zwift program and you probably have to remove the volume.

podman volume rm zwift-xxxxx

Where xxxx is your userid, then re-try. Latest should just work with Wayland and X11 under podman and docker.

joekm commented 6 months ago

Not working under Wayland, will work under X11 if I run "xhost +" first. Also, when I listed my podman volumes, I got

zwift-jkmooney zwift-naeva

The former is my username, don't know what the latter is.

sHedC commented 6 months ago

Not working under Wayland, will work under X11 if I run "xhost +" first. Also, when I listed my podman volumes, I got

zwift-jkmooney zwift-naeva

The former is my username, don't know what the latter is.

Hi, please delete both, the naeva was something I noticed to when I started testing to fix, not sure where it came from but delete it it should not appear anymore.

Ok just to confirm you re-updated the latest zwift script from git hub using Curl? It downloaded the latest

in the zwift you can compare what you have in /usr/local/bin with the zwift.sh in the repo to make sure you are up to date.

What do you see did it open then crash after update? I saw this once but after it was stable.

What OK I think Fedora and Gnome What Card (I can't test Intel but have Nvidia/ AMD dGPU and iGPU and Virt IO GL and SPice etc so can easliy test) If Nvidia what drivers Noveau or Nvidia.

Sorry also podman/ docker and what environment variables.

Thanks

joekm commented 6 months ago

I did reinstall zwift using curl. I'm currently on business travel so it will be middle of next week before I can try again.

On Mon, May 13, 2024, 2:58 AM Richard Holmes @.***> wrote:

Not working under Wayland, will work under X11 if I run "xhost +" first. Also, when I listed my podman volumes, I got

zwift-jkmooney zwift-naeva

The former is my username, don't know what the latter is.

Hi, please delete both, the naeva was something I noticed to when I started testing to fix, not sure where it came from but delete it it should not appear anymore.

Ok just to confirm you re-updated the latest zwift script from git hub using Curl? It downloaded the latest

in the zwift you can compare what you have in /usr/local/bin with the zwift.sh in the repo to make sure you are up to date.

What do you see did it open then crash after update? I saw this once but after it was stable.

What OK I think Fedora and Gnome What Card (I can't test Intel but have Nvidia/ AMD dGPU and iGPU and Virt IO GL and SPice etc so can easliy test) If Nvidia what drivers Noveau or Nvidia.

Thanks

— Reply to this email directly, view it on GitHub https://github.com/netbrain/zwift/issues/88#issuecomment-2106794686, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA76BALFN2F3NDLPHBWBAN3ZCBQB7AVCNFSM6AAAAABGBMEWC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWG44TINRYGY . You are receiving this because you commented.Message ID: @.***>

sHedC commented 6 months ago

Hi, I read ealier your setup forgot we already discussed, I see that in some cases the XAuthority does not seem to work, when you get back can you check what XAUTHORITY contains on your host please.

sHedC commented 6 months ago

@joekm - Have updated to always use the xhost +local.... for both X11 and XWayland, hopfully this works on all distributions.

joekm commented 6 months ago

Under Wayland: echo $XAUTHORITY comes up blank. Similarly ~/.Xauthority exists, but is an empty file.

Under X11: echo $XAUTHORITY gives me a cookie file in the /tmp directory.

With latest update to Zwift.sh, X11 is working fine but Wayland fails to launch with the following message:

Error: host directory cannot be empty

sHedC commented 6 months ago

Anything in the log before, that line is saying that the container failed to run, can you post what the container command is too please :)

CONTAINER=$($podman .....) for example.

joekm commented 6 months ago

I'll dive more into it when I have some time but it kind of looks like it's not getting something to assign to CONTAINER...

sHedC commented 6 months ago

Its the XAUTHROITY bit, its blank which is not good, did you say which distro you are on, seems XAuthority is not used.

I think for your case we need to add a check for XAUTHORITY and if blank probably enable xhost, I assume you have xhost installed.

joekm commented 6 months ago

I'm running EndeavourOS (pretty close to Arch). The window manager is Hyprland. I've tried launching this on Hyprland by running "xhost +" first but it still doesn't work. (I do have xhost installed). . The other desktop I have installed is XFCE (which is X11) and this runs just fine on that.

sHedC commented 6 months ago

Never tried EndevourOS will spin it up, also not yet tried hyperland but interested to see what it would offer me.

joekm commented 6 months ago

poking around, this looks like it may impact both Hyprland and Sway desktops on Arch.

sHedC commented 6 months ago

I have hyperland installed and see the same error, its down to xauthority not sure what yet.

sHedC commented 6 months ago

Can you edit the /usr/local/bin/zwift and comment out the line -v $XAUTHORITY:$(echo $XAUTHORITY | sed 's/'$UID'/'$ZWIFT_UID'/') as shown below.

Hyperland doesn't need XAUTHORITY to release the window, I will put an update in the latest updates I have ongoing.

# Setup Wayland Usage.
if [[ ! -z $WAYLAND_DISPLAY ]]
then
    if [[ ! -z $WINE_EXPERIMENTAL_WAYLAND ]]
    then
        # Using Experimental Wayland, setup required parameters
        # To force wayland DISPLAY must be blank.
        WAYLAND_FLAGS=(
            -e XDG_RUNTIME_DIR=/run/user/$ZWIFT_UID
            -e PULSE_SERVER=/run/user/$ZWIFT_UID/pulse/native
            -e WINE_EXPERIMENTAL_WAYLAND=1
        )
    else

        WAYLAND_FLAGS=(
            --hostname $HOSTNAME
            -e PULSE_SERVER=/run/user/$ZWIFT_UID/pulse/native
            # -v $XAUTHORITY:$(echo $XAUTHORITY | sed 's/'$UID'/'$ZWIFT_UID'/')
        )
    fi
else
    X11_FLAGS=(
        --hostname $HOSTNAME
        -v $XAUTHORITY:$(echo $XAUTHORITY | sed 's/'$UID'/'$ZWIFT_UID'/')
    )
fi
sHedC commented 6 months ago

Yes so hyprland is not using XAUTHORITY however xhost by default allows local user to run X Programs so commenting this out should work.

I have updated the script in the latest pull request.

joekm commented 6 months ago

That seems to have fixed it on Hyprland, thanks :). From what I was reading this morning, it's possible Sway may have the same issue (or maybe any Wayland Compositor/Window Manager).

sHedC commented 6 months ago

possibly, I don't know sway either. Basically the current preferred way is to use Xauthority, in these cases default is disable access and Xauthority gives access.

However I was reading some compositors and WM's don't use xauthority, in Hyperlands case when starting it automatically adds xhost +SI:localhost:. xhost is not installed by default on EndevourOS I found.

If neither xauthority or xhost access is set then no x applications would work so I think it might be safe to assume its going to be one or the other.

So I updated the latest pull to check for xauthority first then if not there assume access is defined by xhost rules and we can see if we get other issues. Would be easier to figure out:

I'll close this thread once we have the merges reviewed/ updated and merged.

sHedC commented 6 months ago

Latest is released, please re-install zwift from following instructions in the README.

When I ran it complained about an existing container which I remeoved using podman container rm zwift-xxxxx but that could just be because I have been messing and left it around.

joekm commented 6 months ago

Can confirm it's working on both Hyprland (Wayland) and XFCE (X11). Thanks again and ride on :)