Closed zrz4066 closed 1 year ago
Thanks for your bug report. Would it be possible for you to attach the .slint file that you're using to reproduce this, or the entire project?
One more question: Did you set the SLINT_LINE_BY_LINE
environment variable by chance?
This is the surrounding code that's panicking:
if std::env::var_os("SLINT_LINE_BY_LINE").is_none() {
let mut buffer = vec![
PremultipliedRgbaColor::default();
width.get() as usize * height.get() as usize
];
self.renderer.render(buffer.as_mut_slice(), width.get() as usize);
for i in 0..target_buffer.len() {
let pixel = buffer[I]; // <-- Line 74 that's panicking
target_buffer[i] = (pixel.alpha as u32) << 24
| ((pixel.red as u32) << 16)
| ((pixel.green as u32) << 8)
| (pixel.blue as u32);
}
} else {
This project generate by the rust template.I don't set SLINT_LINE_BY_LINE.
ice@DESKTOP-OH5PBNG:~/rust/myguitest$ cat src/main.rs slint::include_modules!();
fn main() -> Result<(), slint::PlatformError> { let ui = AppWindow::new()?;
let ui_handle = ui.as_weak();
ui.on_request_increase_value(move || {
let ui = ui_handle.unwrap();
ui.set_counter(ui.get_counter() + 1);
});
ui.run()
}
ice@DESKTOP-OH5PBNG:~/rust/myguitest$ cat ui/appwindow.slint import { Button, VerticalBox } from "std-widgets.slint";
export component AppWindow inherits Window {
in-out property
I'm attempting a fix in https://github.com/slint-ui/slint/pull/3417
It is possible that softbuf allocates a buffer that is too large. (and therefore larger than the buffer we allocate)
Did you set the SLINT_LINE_BY_LINE environment variable by chance?
It was not set because the code that panics is guarded by a is_none
I'm attempting a fix in #3417
It is possible that softbuf allocates a buffer that is too large. (and therefore larger than the buffer we allocate)
Yes indeed. I've made a fix at https://github.com/rust-windowing/softbuffer/pull/148 (it's reproducible on x11 when not using shm)
Cargo.toml is as following, the slint path point to "git = "https://github.com/slint-ui/slint",.There are some errors when compiling
ice@DESKTOP-OH5PBNG:~/rust/myguitest$ cat Cargo.toml [package] name = "myguitest" version = "0.1.0" authors = ["ice"] edition = "2021" build = "build.rs"
[dependencies] slint = { git = "https://github.com/slint-ui/slint", version = "*"}
[build-dependencies] slint-build = "*"
Compiling glow v0.12.3
Compiling lru v0.10.1
Compiling as-raw-xcb-connection v1.0.0
Compiling x11-clipboard v0.7.1
Compiling femtovg v0.7.1
Compiling cpp v0.5.9
Compiling wayland-client v0.30.2
Compiling smithay-clipboard v0.6.6
Compiling i-slint-common v1.2.0
Compiling i-slint-backend-winit v1.3.0 (https://github.com/slint-ui/slint#6e113272)
Compiling i-slint-compiler v1.3.0 (https://github.com/slint-ui/slint#6e113272)
Compiling copypasta v0.8.2
Compiling i-slint-renderer-femtovg v1.3.0 (https://github.com/slint-ui/slint#6e113272)
Compiling i-slint-backend-selector v1.3.0 (https://github.com/slint-ui/slint#6e113272)
Compiling accesskit_unix v0.5.2
Compiling send_wrapper v0.6.0
Compiling accesskit_winit v0.14.4
Compiling slint-build v1.2.0
Compiling myguitest v0.1.0 (/home/ice/rust/myguitest)
Compiling slint-macros v1.3.0 (https://github.com/slint-ui/slint#6e113272)
Compiling slint v1.3.0 (https://github.com/slint-ui/slint#6e113272)
error[E0412]: cannot find type VersionCheck_1_2_0 in crate slint
--> /home/ice/rust/myguitest/target/debug/build/myguitest-45be4991feaaf0e3/out/appwindow.rs:2461:87 |
2461 | ...E : slint :: VersionCheck_1_2_0 = slint :: VersionCheck_1_2_0 ; | ^^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: VersionCheck_1_3_0 |
---|
::: /home/ice/.cargo/git/checkouts/slint-8153123e5dffa129/6e11327/api/rs/slint/lib.rs:300:1
|
300 | pub struct VersionCheck_1_3_0;
| ----------------------------- similarly named struct VersionCheck_1_3_0
defined here
error[E0425]: cannot find value VersionCheck_1_2_0 in crate slint
--> /home/ice/rust/myguitest/target/debug/build/myguitest-45be4991feaaf0e3/out/appwindow.rs:2461:117 |
2461 | ...= slint :: VersionCheck_1_2_0 ; | ^^^^^^^^^^^^^^^^^^ help: a unit struct with a similar name exists: VersionCheck_1_3_0 |
---|
::: /home/ice/.cargo/git/checkouts/slint-8153123e5dffa129/6e11327/api/rs/slint/lib.rs:300:1
|
300 | pub struct VersionCheck_1_3_0;
| ----------------------------- similarly named unit struct VersionCheck_1_3_0
defined here
Some errors have detailed explanations: E0412, E0425.
For more information about an error, try rustc --explain E0412
.
error: could not compile myguitest
(bin "myguitest") due to 2 previous errors
slint and slint-build must have the exact same version. So you need to use the git version of slint-build as well
After modify the Corgo.toml ,Compile ok and slint demo run with no error. The UI is something strange, no Button and no counter.
ice@DESKTOP-OH5PBNG:~/rust/myguitest$ cat ui/appwindow.slint import { Button, VerticalBox } from "std-widgets.slint";
export component AppWindow inherits Window {
in-out property
I can reproduce this issue (by disabling shm transport).
It works with https://github.com/rust-windowing/softbuffer/pull/148 , so I think for the wire transport to work we'll need to wait for a new soft buffer release. I don't know if there's another way to work around this issue within Slint.
Your best workaround at the moment might be to switch the windowing system within your WSL to wayland. Is that a possibility for you?
I verified that the latest softbuffer 0.3.1 release fixes this issue. Just run cargo update
once to update your lock file and rebuild :-)
(commit https://github.com/slint-ui/slint/commit/906430416f9f332a6ce3b168a8f0250b8a751bee bumps this in the master branch)
The slint demo panic after calling run ,slint version:1.2
Compiling copypasta v0.8.2 Compiling i-slint-renderer-femtovg v1.2.0 Compiling i-slint-backend-selector v1.2.0 Compiling send_wrapper v0.6.0 Compiling slint-build v1.2.0 Compiling accesskit_unix v0.5.2 Compiling slint-macros v1.2.0 Compiling myguitest v0.1.0 (/home/ice/rust/myguitest) Compiling accesskit_winit v0.14.4 Compiling slint v1.2.0 Finished dev [unoptimized + debuginfo] target(s) in 2m 39s ice@DESKTOP-OH5PBNG:~/rust/myguitest$ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.24s Running
target/debug/myguitest
thread 'main' panicked at 'index out of bounds: the len is 8349 but the index is 8349', /home/ice/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/i-slint-backend-winit-1.2.0/renderer/sw.rs:74:29 note: run withRUST_BACKTRACE=1
environment variable to display a backtrace//ubuntu .-/+oossssoo+/-. ice@DESKTOP-OH5PBNG
:+ssssssssssssssssss+:
------------------- -+ssssssssssssssssssyyssss+- OS: Ubuntu 20.04.6 LTS on Windows 10 x86_64 .ossssssssssssssssssdMMMNysssso. Kernel: 5.10.16.3-microsoft-standard-WSL2 /ssssssssssshdmmNNmmyNMMMMhssssss/ Uptime: 36 mins +ssssssssshmydMMMMMMMNddddyssssssss+ Packages: 1254 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Shell: bash 5.0.17 .ssssssssdMMMNhsssssssssshNMMMdssssssss. Resolution: 1904x1001 +sssshhhyNMMNyssssssssssssyNMMMysssssss+ WM: Xfwm4 ossyNMMMNyMMhsssssssssssssshmmmhssssssso WM Theme: Default ossyNMMMNyMMhsssssssssssssshmmmhssssssso Theme: Adwaita [GTK3] +sssshhhyNMMNyssssssssssssyNMMMysssssss+ Icons: Adwaita [GTK3] .ssssssssdMMMNhsssssssssshNMMMdssssssss. Terminal: /dev/pts/1 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ CPU: Intel i5-8265U (8) @ 1.800GHz +sssssssssdmydMMMMMMMMddddyssssssss+ GPU: Microsoft Corporation Device 008e /ssssssssssshdmNNNNmyNMMMMhssssss/ Memory: 248MiB / 12542MiB .ossssssssssssssssssdMMMNysssso. -+sssssssssssssssssyyyssss+-:+ssssssssssssssssss+:
.-/+oossssoo+/-.