Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert when using % sizes in Flickable #4163

Closed
csavels opened this issue Dec 14, 2023 · 8 comments · Fixed by #4223
Closed

assert when using % sizes in Flickable #4163

csavels opened this issue Dec 14, 2023 · 8 comments · Fixed by #4223
Assignees
Labels
a:compiler Slint compiler internal (not the codegen, not the parser) bug Something isn't working

Comments

@csavels
Copy link

csavels commented Dec 14, 2023

Hello,

I'm having a problem compiling my Rust application after upgrading to Rust+Slint without modifying the code.
I was using the "Slint 1.2" version before the update. Now the application no longer compiles and returns the error:

index.crates.io-6f17d22bba15001f/i-slint-compiler-1.3.2/passes/default_geometry.rs:281:9:
assertion left == right failed
left: Invalid
right: LogicalLength

Config:

OS: macOS 14.1.1 (23B81)
Language: Rust 1.74.1
Slint: 1.3.2
Slint-build : 1.3.2

What differences between the two versions could cause this?
(app code is really too big to be shared).

Thanks already.

@tronical tronical added bug Something isn't working a:compiler Slint compiler internal (not the codegen, not the parser) labels Dec 15, 2023
@tronical
Copy link
Member

Thanks for the report - this looks indeed like a bug.

What differences between the two versions could cause this?

That's a good question...

This would happen if an element uses a percentage width or height binding (width: 30%;) and the parent has a width/height property that however has a type that's not length. I can't think of any built-in element that could cause this, nor can I reproduce it using an empty base or an attempt at overriding width/height.

Do you have any percentage width/height bindings? Could you check what the surrounding code looks like? (and paste it here, if possible - just an excerpt)

@ogoffart Do you have any idea what could cause this?

@ogoffart
Copy link
Member

A lot changed in 1.3 with regards to height and width properties.

But it would be useful to have some code that reproduce the issue so we can debug it.

@ogoffart ogoffart added the needs info Further information from the reporter is requested label Dec 18, 2023
@ogoffart
Copy link
Member

In order to be able to debug this issue, i'd need to access some code that reproduces the issue.
Would you be able to share (even privately) that code?

@ian373
Copy link

ian373 commented Dec 23, 2023

@ogoffart I ran into the same error in slint 1.3.1, and here's an example to illustrate it:

  • OS: win11 22H2
  • rustc: 1.73.0 (cc66ad468 2023-10-03)

cargo.toml

[package]
name = "xxx"
version = "0.1.0"
edition = "2021"

[dependencies]
slint = "1.3.1"
[build-dependencies]
slint-build = "1.3.1"

main.rs

slint::include_modules!();

fn main() {
    MainWindow::new().unwrap().run().unwrap();
}

appwindow.slint

import { ListView } from "std-widgets.slint";
component ShowResult inherits Rectangle {
    width: 50%;
    height: 100%;

    VerticalLayout {
        ListView {
            for file[idx] in [1,2,3]:Rectangle {
                height: 20px;
                // width: parent.width;    // change to this line compiles fine
                width: 100%;  // An error occurred!!!
            }
        }
    }
}
export component MainWindow inherits Window {
    width: 326px;
    height: 326px;

    HorizontalLayout {
        width: 100%;
        height: 100%;

        ShowResult {}
    }
}

error:
tw

@csavels
Copy link
Author

csavels commented Dec 25, 2023

Hello,
Sorry for the delay in responding.

My UI is composed of more than 100 files, so it's hard to share, but my code is similar to the one copied as an example by "ian373".

Why does the percentage no longer work?
Without the percentage, padding was ignored in previous versions of Slint, which is why I used it everywhere.

@csavels
Copy link
Author

csavels commented Dec 25, 2023

Another tip: the Slint preview is still working, but I can't compile the code.

stack backtrace:
0: 0x1037fca28 - std::backtrace_rs::backtrace::libunwind::trace::hf755a955ad018943
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x1037fca28 - std::backtrace_rs::backtrace::trace_unsynchronized::hde69ab8e2b667964
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x1037fca28 - std::sys_common::backtrace::_print_fmt::hf6c414569af631f5
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:67:5
3: 0x1037fca28 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0524bd1b527203b8
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:44:22
4: 0x103818818 - core::fmt::rt::Argument::fmt::ha0532872e39381ee
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/fmt/rt.rs:138:9
5: 0x103818818 - core::fmt::write::h74be1333b0a6ddea
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/fmt/mod.rs:1114:21
6: 0x1037f9e40 - std::io::Write::write_fmt::h6c011b665b2d7d4b
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/io/mod.rs:1763:15
7: 0x1037fc868 - std::sys_common::backtrace::_print::hcc60dadc0e4df78f
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:47:5
8: 0x1037fc868 - std::sys_common::backtrace::print::he25ff7dac6402434
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:34:9
9: 0x1037fde68 - std::panicking::default_hook::{{closure}}::h41763ba018b93bf7
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:272:22
10: 0x1037fdb80 - std::panicking::default_hook::h017c44660373840e
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:292:9
11: 0x1037fe3ac - std::panicking::rust_panic_with_hook::h221a0baf52ecd48a
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:731:13
12: 0x1037fe2b4 - std::panicking::begin_panic_handler::{{closure}}::h18b661cf0f97a414
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:609:13
13: 0x1037fceb4 - std::sys_common::backtrace::__rust_end_short_backtrace::h4f4b2ffab2311217
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:170:18
14: 0x1037fe020 - rust_begin_unwind
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
15: 0x1038410d8 - core::panicking::panic_fmt::hd6070cd222575be5
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
16: 0x103841460 - core::panicking::assert_failed_inner::h435b21d414fe4cfd
17: 0x10382e5e0 - core::panicking::assert_failed::h13d36bf8befbeaad
18: 0x102e4869c - i_slint_compiler::passes::default_geometry::fix_percent_size::h86c0b3ced87e365c
19: 0x102e44e18 - i_slint_compiler::passes::default_geometry::default_geometry::{{closure}}::hdeb9899c33a5a404
20: 0x10310d9bc - i_slint_compiler::object_tree::recurse_elem_including_sub_components::{{closure}}::h17839ccd085a1b09
21: 0x103109e64 - i_slint_compiler::object_tree::recurse_elem::h6a61c727bd4dd9fd
22: 0x103109f7c - i_slint_compiler::object_tree::recurse_elem::h6a61c727bd4dd9fd
23: 0x103109f7c - i_slint_compiler::object_tree::recurse_elem::h6a61c727bd4dd9fd
24: 0x103109f7c - i_slint_compiler::object_tree::recurse_elem::h6a61c727bd4dd9fd
25: 0x103109f7c - i_slint_compiler::object_tree::recurse_elem::h6a61c727bd4dd9fd
26: 0x103109f7c - i_slint_compiler::object_tree::recurse_elem::h6a61c727bd4dd9fd
27: 0x10310d2f0 - i_slint_compiler::object_tree::recurse_elem_including_sub_components::hf93c6269c417c6eb
28: 0x102e44d2c - i_slint_compiler::passes::default_geometry::default_geometry::h77d85cfa23428523
29: 0x102d3d978 - i_slint_compiler::passes::run_passes::{{closure}}::h0233a43448f892a3
30: 0x102d37edc - i_slint_compiler::compile_syntax_node::{{closure}}::h676fdd22b6e02281
31: 0x102d23594 - spin_on::spin_on::h36ca0e6873542373
32: 0x102d52720 - slint_build::compile_with_config::hcf3cd08b8fa2496a
33: 0x102d53744 - slint_build::compile::h753662bc80945ebc
34: 0x102d32978 - build_script_build::main::hd7ce96fed83b2854
35: 0x102d30a34 - core::ops::function::FnOnce::call_once::h5c998fdf23aa9f17
36: 0x102d40c4c - std::sys_common::backtrace::__rust_begin_short_backtrace::haa4cf23086652034
37: 0x102d34260 - std::rt::lang_start::{{closure}}::h7ecd142d863bbd44
38: 0x1037f4cd0 - core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once::h44482c562109b08c
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/ops/function.rs:284:13
39: 0x1037f4cd0 - std::panicking::try::do_call::h627d61d518625eaf
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:504:40
40: 0x1037f4cd0 - std::panicking::try::h487b8df834773e7d
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:468:19
41: 0x1037f4cd0 - std::panic::catch_unwind::h5d4366c6f71d3443
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panic.rs:142:14
42: 0x1037f4cd0 - std::rt::lang_start_internal::{{closure}}::h749338e1cc06c4f7
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/rt.rs:148:48
43: 0x1037f4cd0 - std::panicking::try::do_call::h2098bd254e5cae95
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:504:40
44: 0x1037f4cd0 - std::panicking::try::h7bfd8a0246bca0f8
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:468:19
45: 0x1037f4cd0 - std::panic::catch_unwind::h6da51257cc975c65
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panic.rs:142:14
46: 0x1037f4cd0 - std::rt::lang_start_internal::h5f00c09289a72e67
at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/rt.rs:148:20
47: 0x102d3423c - std::rt::lang_start::h297d850e9d95d25d
48: 0x102d329b8 - _main

@ogoffart ogoffart self-assigned this Dec 27, 2023
@ogoffart
Copy link
Member

It works with the preview because this is a debug_assert failing and the preview is compiled in release.

The failling code can be reduced to this:

  Flickable { Rectangle { width: 100% } }

What should the 100% be relative to? To the viewport or to the flickable?
parent.width is relative to the flickabled
But by the time we try to compute the size of 100%, there is a viewport inbetween.
The assert is

debug_assert_eq!(
            parent.borrow().lookup_property(property).property_type,
            Type::LogicalLength
        );

And this fails for the Flickable viewport because lookup_property does't check the reserved builtin property for a ElementType::Native (which the viewport is)

@ogoffart ogoffart added a:language-slint Compiler for the .slint language (mO,bF) and removed needs info Further information from the reporter is requested labels Dec 27, 2023
ogoffart added a commit that referenced this issue Dec 27, 2023
The viewport of a flickable is of ElementType::Native, and `lookup_property`
don't query the builtin reserved properties in that case.

This commit fix the assert by allowing Type::Invalid as well.

Fixes #4163
@csavels
Copy link
Author

csavels commented Dec 27, 2023

Hello,

I modified all my pages this morning (outch!) and now it works.
I've removed all use of a percentage and replaced it with "parent.length - padding".
I'll never use the percentage again to avoid problems.
Thanks for your help.

@ogoffart ogoffart removed the a:language-slint Compiler for the .slint language (mO,bF) label Jan 15, 2024
@ogoffart ogoffart changed the title Rust: Compilation crash after update to version 1.3.2 assert when using % sizes in Flickable Jan 22, 2024
ogoffart added a commit that referenced this issue Sep 11, 2024
The viewport of a flickable is of ElementType::Native, and `lookup_property`
don't query the builtin reserved properties in that case.

This commit fix the assert by allowing Type::Invalid as well.

Fixes #4163
ogoffart added a commit that referenced this issue Sep 11, 2024
The viewport of a flickable is of ElementType::Native, and `lookup_property`
don't query the builtin reserved properties in that case.

This commit fix the assert by allowing Type::Invalid as well.

Fixes #4163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:compiler Slint compiler internal (not the codegen, not the parser) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants