microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.22k stars 808 forks source link

Support Wayland protocol to allow GUI apps to work. #938

Closed barry-scott closed 3 years ago

barry-scott commented 8 years ago

Given the Linux world is moving to Wayland as the step on from X11 it would be good to see Wayland supported in WSL.

Off the top of my head think there is enough protocol/API to completely isolate a windows Wayland server as part of the normal windows desktop from the wayland clients running in WSL.

All the important GUI tool kits have Wayland support today and its will become mainstream on Linux distros on the next year.

At this point in time doing work for X11 may be wasted effort.

Zubnix commented 4 years ago

ps. I also installed the ubuntu distro before going with docker, not sure if that is needed. I guess not, so I've left it out from above steps.

craigloewen-msft commented 4 years ago

Hi folks, I'm happy to announce that we are putting supporting GUI apps in WSL on our roadmap. I'll add an edit to this post with more details today!

And here are the details on our blog post. Can't wait to make this possible!

barry-scott commented 4 years ago

That is wonderful news.

hwti commented 4 years ago

Will the Wayland => RDP stack support GPU acceleration too, when everything is in place (Mesa, dxgkrnl, ...), so wayland-egl applications would work ? Or will it be limited to wayland-shm ?

craigloewen-msft commented 4 years ago

Hi folks, we would love to hear your input on this request! Please fill out this survey and let us know what Linux GUI apps you'd want to use. It will help shape the priorities for the team as we build this feature!

https://forms.office.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbRzbKcfZyZQ9Drbxd4NOp_ZBUOFZVQ1A2UUlWRzBNMUtPOFFVVkRQWTNRQS4u

Thank you

chewi commented 4 years ago

As the maintainer of the Weston package in Gentoo Linux, I am already familiar with it. I've now been using it for a few weeks under Ubuntu on WSL but connecting from a remote Linux desktop with FreeRDP. This suits my monitor setup and Barrier allows me to easily share my keyboard and mouse between the two systems. The performance is surprisingly good considering that there's still no GPU acceleration. The only annoyance is the lack of clipboard support.

I'm very interested to see what Microsoft are working on in this area. Weston is an open source project so is there a fork somewhere that we can try out? Probably not but thought it was worth asking!

Trass3r commented 4 years ago

I tried to set up Weston RDP but in the end VcXsrv is still much more user-friendly until MS publishes their solution.

CTimmerman commented 4 years ago

The only annoyance is the lack of clipboard support.

I wrote a Python script to solve that problem: https://gist.github.com/CTimmerman/370271d0519f3c8db749

francescarpi commented 4 years ago

I tried to set up Weston RDP but in the end VcXsrv is still much more user-friendly until MS publishes their solution.

Could you explain how, please?

Thank you so much.

Trass3r commented 4 years ago

From the history it looks like I had to manually set XDG_RUNTIME_DIR, then generate keys with openssl and then tried weston --backend=rdp-backend.so --rdp-tls-key=tls.ley --rdp-tls-cert=tls.crt --address=127.0.0.1 --port=3390 which failed iirc cause I tried xrdp next which worked after changing the config sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini iirc but I couldn't log in via RD. With greenfield it's completely unclear to me how you actually get your own application to show up and LoWe requires building stuff on the Linux and Windows side.

For X you just need echo "export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0" >> ~/.bashrc and no login is required. Maybe that host ip is also needed for Weston to work.

chewi commented 4 years ago

You need to bind to 0.0.0.0 rather than 127.0.0.1. My Weston options are otherwise the same. I did this to expose Weston to the remote machine.

netsh interface portproxy add v4tov4 listenport=8389 listenaddress=0.0.0.0 connectport=3390 connectaddress=127.0.0.1

Annoyingly Microsoft's own RDP client won't connect to Weston but I can't figure out why.

yqu212 commented 4 years ago

@chewi @Trass3r Can you present your setup with details? A blog post is welcomed. Thank you.

Ferk commented 4 years ago

Annoyingly Microsoft's own RDP client won't connect to Weston but I can't figure out why.

Are you getting the "you already have a session in progress" error? Apparently that always happens whenever connecting to localhost on the default port (it doesn't even attempt to connect).

Try changing to a non-standard port (different than 3390) or use a different loopback IP.

I've got Microsoft's RDP to initiate connection with weston-rdp, although I'm getting some other error immediately afterwards.

[22:09:22:592] [453:453] [ERROR][com.freerdp.core.transport] - BIO_read returned a system error 0: Success
[22:09:22:592] [453:453] [ERROR][com.freerdp.core] - transport_read_layer:freerdp_set_last_error_ex ERRCONNECT_CONNECT_TRANSPORT_FAILED [0x0002000D]
[22:09:22.011] unable to checkDescriptor for 0x558fc79d1c60
chewi commented 4 years ago

3389 is the standard port, not 3390, so I don't see the "you already have a session in progress" error. The other error you included is the one I was referring to.

chewi commented 4 years ago

I've since switched to Xpra, which performs very well when connecting remotely and has far more features. Apart from a working clipboard, I particularly like the way it handles the opening of URLs, prompting whether you'd like to open them in the local or remote browser, and also the XDG menu integration, providing an application menu through the native tray icon. Sadly the client isn't working very well for me on Windows but I'm speaking to upstream about that.

Trass3r commented 4 years ago

How did you set it up?

rcsilva83 commented 3 years ago

Any news about the official support for Wayland?

onomatopellan commented 3 years ago

@rcsilva83 I recommend this video: WSL Graphics Architecture (Jesse Natalie & Steve Pronovost) X11 and Wayland applications in WSL (Steve Pronovost)

It's coming "soon". I think in a month Insiders should get the first bits.

chewi commented 3 years ago

Thanks for posting those. I watched them both in full, as well as the Mesa one afterwards, and they were really fascinating. I think Microsoft's approach here is fantastic and I was pleasantly surprised to see them equally supporting my less common use case of running these GUI applications remotely.

dxgldotorg commented 3 years ago

When it comes to Windows Insider will there be any potential conflicts with VcXsrv?

onomatopellan commented 3 years ago

@dxgldotorg No conflicts. You will be able to disable it with an option in the .wslconfig file.

dxgldotorg commented 3 years ago

No conflicts would mean I wouldn't have to stop my X server in order to use the new feature, right?

onomatopellan commented 3 years ago

@dxgldotorg They only said about disabling the new feature. See https://www.youtube.com/watch?v=b2mnbyRgXkY&feature=youtu.be&t=9754

pan3793 commented 3 years ago

@rcsilva83 I recommend this video: WSL Graphics Architecture (Jesse Natalie & Steve Pronovost) X11 and Wayland applications in WSL (Steve Pronovost)

It's coming "soon". I think in a month Insiders should get the first bits.

Any update on it?

craigloewen-msft commented 3 years ago

We are still working on this feature! We don't yet have an ETA but will post here once we do.

NatElkins commented 3 years ago

Does this feature exist as a preview anywhere? I would love to give this a spin.

valorl commented 3 years ago

Will it be possible to run a Wayland WM like Sway this way? Similarly to how nowadays you can use an X client in Windows and run a window manager in WSL.

TingPing commented 3 years ago

Will it be possible to run a Wayland WM like Sway this way? Similarly to how nowadays you can use an X client in Windows and run a window manager in WSL.

A nested compositor would work, but that isn't going to be what you want as it would be in its own window. You'd likely have to modify Sway to function.

valorl commented 3 years ago

Will it be possible to run a Wayland WM like Sway this way? Similarly to how nowadays you can use an X client in Windows and run a window manager in WSL.

A nested compositor would work, but that isn't going to be what you want as it would be in its own window. You'd likely have to modify Sway to function.

Thanks. That actually is what I want and do right now. I mostly spend time in my WSL, so I just run the full (tiling) WM in one fullscreen window on my main display.

Zingam commented 3 years ago

For my development needs I'd like to have full support:

I hope to get a great and stable multimedia platform and to be able to target it from Visual Studio 2019 (Code), so I can seamlessly switch between Windows/Linux and other targets.

Biswa96 commented 3 years ago

For my development needs I'd like to have full support

What does prevent you to use an actual installation of a GNU/Linux distribution or any other unix-like OSes?

Zingam commented 3 years ago

@Biswa96 Technically nothing. It's a matter of convenience.

3kynox commented 3 years ago

Will it be possible to run a Wayland WM like Sway this way? Similarly to how nowadays you can use an X client in Windows and run a window manager in WSL.

A nested compositor would work, but that isn't going to be what you want as it would be in its own window. You'd likely have to modify Sway to function.

@valorl I would love having it as well. Either in its own windows or being able to stream apps independently of the desktop os window. Up to give a hand in this adaptation. I will definitely appreciate my arch + sway setup at the end!

craigloewen-msft commented 3 years ago

We released the first preview of this work today! Please see the blog post here for all the details: https://devblogs.microsoft.com/commandline/the-initial-preview-of-gui-app-support-is-now-available-for-the-windows-subsystem-for-linux-2/

Zingam commented 3 years ago

Build, test and use Linux applications that use audio or the microphone with built in audio support

I like that :)

Bonus: Leverage WSL’s GPU access to run Linux applications with 3D acceleration

Why is that considered a bonus? 3D isn't a bonus since 20 years?

Biswa96 commented 3 years ago

In that blog post, the diagram of the architecture does not explain the role of WSLGd binary. More info will be helpful.

tianon commented 3 years ago

@Biswa96 you're probably looking for the lower-level sister blog post: https://devblogs.microsoft.com/commandline/wslg-architecture/ :smile:

chewi commented 3 years ago

@craigloewen-msft Thanks so much! I was really impressed with your presentations at XDC last year. This has been so well architected so congratulations on getting it out the door.

For the time being though, unlike most users, I'm actually more interested in RAIL than VAIL. Are there any instructions on connecting remotely? I imagine you can just fire up Weston and connect, much like I was doing before, only it should work much better now? I've found Microsoft's Weston fork so I could build this or maybe I could run your existing image with Docker somehow?

craigloewen-msft commented 3 years ago

@Zingam I put 'Bonus' since it's a pretty exciting feature and as of right now requires preview versions of software but will soon be fully available on every distro, I get your point though!

@chewi that's an interesting point. We haven't explicitly built WSLg to do this, but it is open sourced as you mentioned so you could take a look and see if you could get it working.

3kynox commented 3 years ago

Hey guys, wonderful news. At the moment I saw this update, I've put my hands on it. Using an Arch distro here, installed the beta Nvidia Cuda drivers, installed gedit on my distro (which installed automatically Mesa-21.0 release) and I can run gui apps which looks like to take into account gpu acceleration.

My problem is it looks like to take the wrong GPU as I have a Optimus system (so an intel card + a Nvidia discrete GPU) + in addition an external more powerful NVidia GPU through Thunderbolt3). I would like to select this last (tb3) GPU.

Any way to do that?

ps: I've made some tests using Gimp, glxgears and a linux game made with Unity3D Engine (ie. https://www.quantex-online-entertainment.net/ ), and it should be on the wrong GPU... as display is jerky.

Thanks in advance for further info.

chewi commented 3 years ago

Well I got RAIL to work. I built replacement Weston and FreeRDP .deb packages for Ubuntu 20.04. I was able to connect using mstsc on Windows (locally with a non-Insider build) and FreeRDP on Linux. With mstsc, I was even able to use "seamless" mode with individual applications. I couldn't get this to work with FreeRDP, even though I'd also patched the client. The server complains with:

HiDef-RAIL is required for RAIL.

That aside, I don't think the performance is any better than it was when I ran the vanilla stack last year. It's not even that good locally. Xpra's performance is much better. I know this is why you've created VAIL but I had hoped it would still be a bit better than it was. On the plus side, the clipboard works now!

therealkenc commented 3 years ago

NVidia GPU through Thunderbolt3). I would like to select this last (tb3) GPU.

External GPU was raised at #5604. It would probably suffice as a landing zone for the GUI use case as well.

3kynox commented 3 years ago

Ok, cool to see there's an issue about it. What about switching to the discrete gpu in the meantime (which is internal to the laptop)? What's the way to do it?I will be a lot better than the intel GPU. I'm up to read some docs.

glxinfo do not give more then that currently:

[nox@NoX NoX]$ glxinfo|egrep "OpenGL vendor|OpenGL renderer"
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 11.1.0, 256 bits)

Thanks anyway

chewi commented 3 years ago

Ah I guess this mail explains the error I saw about "HiDef".

FreeRDP does support the capabilities and messages but the rendering code of xfreerdp does not.

TBBle commented 3 years ago

@3kynox: Maybe I misunderstood, but from the blog post and following into the Mesa 21 release notes, shoudn't the OpenGL renderer string be "d3d12", not "llvmpipe", if it's using the new Wayland setup?

Is it possible that the 3D acceleration is not working at all for you, rather than using the wrong GPU?

Edit: Yeah, the Arch Mesa 21 build does not enable the d3d12 driver. It looks like d3d12 needs to be added to the gallium-drivers list.

3kynox commented 3 years ago

Ok, so a mesa21 build that includes d3d12 is required. You are probably right, I could not have GPU acceleration at all. Thanks @TBBle for direction to take and research.

onomatopellan commented 3 years ago

For a d3d12 enabled Mesa on Ubuntu I recommend the kisak PPA.

sudo add-apt-repository ppa:kisak/kisak-mesa
sudo apt-get update
chewi commented 3 years ago

I can vouch for @kisak-valve as I've frequently worked with him on Steam-related issues.

Zingam commented 3 years ago

Ok, cool to see there's an issue about it. What about switching to the discrete gpu in the meantime (which is internal to the laptop)? What's the way to do it?I will be a lot better than the intel GPU. I'm up to read some docs.

glxinfo do not give more then that currently:

[nox@NoX NoX]$ glxinfo|egrep "OpenGL vendor|OpenGL renderer"
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 11.1.0, 256 bits)

Thanks anyway

Just for the record (I know this was already clarified). llvmpipe is a software rasterizer - https://docs.mesa3d.org/drivers/llvmpipe.html.

bpulliam commented 3 years ago

Closing this issue. For all wslg issues, please file issues in https://github.com/microsoft/wslg/issues.