slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Black window with ubuntu 20.04 #4332

Closed Martoni closed 7 months ago

Martoni commented 8 months ago

Hi, I'm using Slint for a personal project named QRNote. This software works well with Slint version from 1.0.x to 1.2.x but 1.3.x freeze with black window.

$ https://github.com/Martoni/QRNote.git
$ cd QRNote/qr-note
$ cargo clean; cargo run

With Slint 1.2.2 It's work.

With Slint 1.3.2 not. I can't even close the (black) window by clicking on the cross. I have to kill it with Ctrl+C

In Cargo.toml:

[dependencies]
slint = "1.3.*"

I'm using Linux Ubuntu focal :

cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

With rust version 1.72 :

$ rustc -V
rustc 1.72.0 (5680fa18f 2023-08-23)
ogoffart commented 8 months ago

I tested your app on archlinux X11, and it works. Are you using X11 or wayland? Is the problem specific to QRNote, or is any Slint example application impacted? One thing that changed in Slint 1.3 was an upgrade of the winit dependency, this might be related. Could you take a screenshot of the black window?

tronical commented 8 months ago

I tried with Wayland under Ubuntu 23.10 and that worked fine, too. I wonder if this is some incompatibility towards something in Wayland in Ubuntu 20.04?

Martoni commented 8 months ago

Ok, I just tested with another computer which use linux Mint 21 :

$ cat /etc/lsb-release 
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=21
DISTRIB_CODENAME=vanessa
DISTRIB_DESCRIPTION="Linux Mint 21 Vanessa"

And it's works with Slint 1.3.2

Seems to be Ubuntu 20.04 problem.

Martoni commented 8 months ago

Could you take a screenshot of the black window?

Yes ->

Screenshot of the black window

This screenshot has been take on ubuntu 20.04 :

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
ogoffart commented 8 months ago

Can you confirm if this is X11 or wayland? I assume the compositor is the Gnome one. And I assume this is the winit backend with femtovg. Could you try to use the software renderer with SLINT_BACKEND=winit-software env variable, just to double check that this is a problem in the GL stack.

I have also a theory that this might be is caused by the set_transparency(true) in https://github.com/slint-ui/slint/blob/8caa5acd304b1020d3fa6422170d107dc20fa3b8/internal/backends/winit/winitwindowadapter.rs#L190 Could you try to replace the true to false in that line in the dependency. (eg, by edditing the file in the $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i-slint-backend-winit-1.3.2/winitwindowadapter.rs and doing cargo clean and cargo run again?

Martoni commented 8 months ago

Can you confirm if this is X11 or wayland? I assume the compositor is the Gnome one.

I launched this command according to this question.

$ loginctl show-session $(awk '/tty/ {print $1}' <(loginctl)) -p Type | awk -F= '{print $2}'
x11

It's tell me that X11.

If I run it with SLINT_BACKEND=winit-software it the same problem:

$ SLINT_BACKEND=winit-software cargo run

I changed the transparency in file :

$ vim ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i-slint-backend-winit-1.3.2/winitwindowadapter.rs

#line 204 : 
        let mut window_builder =
            winit::window::WindowBuilder::new().with_transparent(true).with_visible(false);
#Changed to
        let mut window_builder =
            winit::window::WindowBuilder::new().with_transparent(false).with_visible(false);

Then recompiled :

$ cargo clean;cargo run

But the result is the same.

tronical commented 8 months ago

I went ahead and installed Ubuntu 20.04.6 LTS in a virtual machine, ran sudo apt get install git build-essential, installed Cargo and Rust from rustup.rs, cloned the above repo, and ran cargo run and it works for me. This was with an X11 Gnome session. I logged out and logged into a Gnome wayland session, but it also still works.

Do you know if you're running Wayland or X11? Do you have the WAYLAND_DISPLAY environment variable set?

Could you try running with SLINT_BACKEND=winit-software and see if that produces a window for you that's not black?

Martoni commented 8 months ago

Do you know if you're running Wayland or X11?

Yes, I'm running X11 :

$ loginctl show-session $(awk '/tty/ {print $1}' <(loginctl)) -p Type | awk -F= '{print $2}'
x11

Do you have the WAYLAND_DISPLAY environment variable set?

No, it's not :

$ echo $WAYLAND_DISPLAY

Could you try running with SLINT_BACKEND=winit-software and see if that produces a window for you that's not black?

No it's still black.

tronical commented 8 months ago

Thanks for getting back. It's rather concerning that not even the software rendering path works. I have two follow-up questions:

  1. What kind of graphics card do you have in your system?
  2. Could you try cloning https://github.com/rust-windowing/softbuffer and run cargo run --example winit and see if that also produces a black window?
Martoni commented 8 months ago
  1. What kind of graphics card do you have in your system?

I think it's a Advanced Micro Devices, Inc. [AMD/ATI] Renoir (rev c6) (prog-if 00 [VGA controller]). My computer is a laptop from tuxedo_computer

  1. Could you try cloning https://github.com/rust-windowing/softbuffer and run cargo run --example winit and see if that also produces a black window?

Of course.

$ cd /tmp/
$ git clone https://github.com/rust-windowing/softbuffer
Cloning into 'softbuffer'...
remote: Enumerating objects: 1314, done.
remote: Counting objects: 100% (773/773), done.
remote: Compressing objects: 100% (228/228), done.
remote: Total 1314 (delta 625), reused 598 (delta 540), pack-reused 541
Receiving objects: 100% (1314/1314), 451.74 KiB | 5.94 MiB/s, done.
Resolving deltas: 100% (834/834), done.
$ cd softbuffer
$ cargo run --example winit

No black window : Screenshot from 2024-01-19 18-18-22

Martoni commented 7 months ago

I upgraded my distribution to Ubuntu 22 now. Then I fixed this bug. Since I had a new bug (Qt library link missing) I think that this problem is not related to Slint but my Linux installation. I'm closing this issue then. Thank for all your help.