Closed BuriKizilkaya closed 1 year ago
Somehow the preview needs to be able to access our X server or wayland compositor, and it appears to be running inside the container. That means you may need to configure your devcontainer to forward for example the DISPLAY
environment variable (for x11). How does your devcontainer.json
look like? What's your host operating system?
I wonder if perhaps we should try to detect this (lack of availability of connection to display) and disable the "Show Preview" functionality. It's a little tricky to do just with winit, because that just panics (we don't get an error), but we could try to look for the corresponding variables yourselves to detect the lack of display.
(Tagging this as a bug, because either there's a way to make it work or we should try to detect and disable "Show Preview" IMO)
Thanks for the bug report.
For this case when the lsp server can't access the display server, there is the "Slint › Preview: Provided By Editor" setting that can be enabled to force it to be rendered with wasm on a tab.
Ideally we'd detect that we are in a dev container and enable that automatically. (We do that for codespace in our master branch already)
But the problem is that winit panics instead of reporting an error we can catch.
I do all my Linux development in containers, too, and had no trouble with Slint so far. I do have wayland/X11 forwarded from the container to the outside machine for it to render UIs, but most dev container tools do set that up for you.
E.g. toolbox
works out of the box.
We should handle the case where no display is found though and forward to the embedded WASM viewer in that case. The user experience you had is horrible, we need to fix that.
The root cause of the preview failing when it can not connect to a display is #204. An oldie but goldie. You can work around the issue nowadays with the WASM previewer.
All this container thing is just a way to produce a situation where no display can be found on Linux. Let's continue with the old issue.
But thank you for taking the time to report your issue, it is aprpeciated!
Hi
Can I use slint inside your devcontainer. I was able to install dependencies and if execute the command
cargo run
, then the Window shows up. If I click on the "Show Preview" Button, then I get the following error:The main issue is
Failed to initialize any backend!
.