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

Infinitely growing layout #2902

Open
tp971 opened this issue Jun 15, 2023 · 4 comments · May be fixed by #3997
Open

Infinitely growing layout #2902

tp971 opened this issue Jun 15, 2023 · 4 comments · May be fixed by #3997
Labels
a:layouts Related to the layouting and positioning of the elements (mO,bT) bug Something isn't working

Comments

@tp971
Copy link

tp971 commented Jun 15, 2023

The following code produces an infinitely growing window:

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

slint::slint! {
    import { HorizontalBox, VerticalBox } from "std-widgets.slint";

    export component MainWindow inherits Window {
        HorizontalBox {
            VerticalBox {
                width: parent.width;
                height: parent.height;
                Text {
                    text: "Test";
                }
            }
        }
    }
}

(the exact behaviour differs between backends, sometimes it doesn't grow or randomly stops growing)

I guess the expected behaviour here is to detect a binding loop?

@ogoffart
Copy link
Member

I can reroduce the problem:
With Qt: the layout grows
With winit: the size is fixed.

We could try to detect that as a binding loop. The question is how. Should we make a link between the width/height of a window and the preferred/minimum/maximum size?
that may break existing application, maybe just a warning?

@ogoffart
Copy link
Member

(This was also tracked in #257 , but i closed it in favor of this one)

@almindor
Copy link
Contributor

almindor commented Jul 5, 2023

This seems similar to what I'm getting with this UI:

import { Button } from "std-widgets.slint";

export component MainWindow inherits Window {
    VerticalLayout {
        width: parent.width;
        height: parent.height;

        Button { 
            text: "Button";
        }

        Rectangle {
            width: parent.width;
            height: parent.height; // this is the problem
        }
    }
}

This produces a black-out window that starts normal but blacks out eventually (on wayland/sway linux).

@ogoffart ogoffart added the a:layouts Related to the layouting and positioning of the elements (mO,bT) label Jul 13, 2023
ogoffart added a commit that referenced this issue Nov 23, 2023
The Window geometry depends on its constraints, so its constraints
cannot depends on its geometry

This fixes Infinitely growing layout, and other panics

Fixes #3989
Fixes #2902
@qarmin
Copy link

qarmin commented Feb 8, 2024

Now with slint lsp (nightly 1.4.1)

    import { HorizontalBox, VerticalBox } from "std-widgets.slint";

    export component MainWindow inherits Window {
        HorizontalBox {
            VerticalBox {
                width: parent.width;
                height: parent.height;
                Text {
                    text: "Test";
                }
            }
        }
    }

I have such panic

thread 'main' panicked at /home/runner/work/slint/slint/internal/core/properties.rs:486:9:
Recursion detected
stack backtrace:
   0: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   2: i_slint_core::properties::Property<T>::get
   3: <field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get
   4: slint_interpreter::eval::load_property_helper
   5: slint_interpreter::eval_layout::get_layout_info
   6: slint_interpreter::dynamic_item_tree::layout_info
   7: slint_interpreter::dynamic_item_tree::COMPONENT_BOX_VT::layout_info
   8: core::ops::function::FnOnce::call_once
   9: i_slint_core::properties::alloc_binding_holder::evaluate
  10: i_slint_core::properties::Property<T>::get
  11: core::ops::function::FnOnce::call_once
  12: i_slint_core::properties::alloc_binding_holder::evaluate
  13: i_slint_core::properties::Property<T>::get
  14: i_slint_core::properties::alloc_binding_holder::evaluate
  15: i_slint_core::properties::Property<T>::get
  16: <i_slint_core::rtti::MaybeAnimatedPropertyInfoWrapper<Item,i_slint_core::properties::Property<T>> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get
  17: <&dyn i_slint_core::rtti::PropertyInfo<Item,slint_interpreter::api::Value> as slint_interpreter::eval::ErasedPropertyInfo>::get
  18: slint_interpreter::eval::load_property_helper
  19: slint_interpreter::eval::eval_expression
  20: slint_interpreter::dynamic_item_tree::make_binding_eval_closure::{{closure}}
  21: i_slint_core::properties::alloc_binding_holder::evaluate
  22: i_slint_core::properties::Property<T>::get
  23: <i_slint_core::rtti::MaybeAnimatedPropertyInfoWrapper<Item,i_slint_core::properties::Property<T>> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get
  24: slint_interpreter::eval::load_property_helper
  25: slint_interpreter::eval::eval_expression
  26: slint_interpreter::dynamic_item_tree::make_binding_eval_closure::{{closure}}
  27: i_slint_core::properties::alloc_binding_holder::evaluate
  28: i_slint_core::properties::Property<T>::get
  29: <i_slint_core::rtti::MaybeAnimatedPropertyInfoWrapper<Item,i_slint_core::properties::Property<T>> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get
  30: slint_interpreter::eval::load_property_helper
  31: slint_interpreter::eval_layout::compute_layout_info::{{closure}}
  32: slint_interpreter::eval_layout::fill_layout_info_constraints
  33: slint_interpreter::eval_layout::compute_layout_info
  34: slint_interpreter::dynamic_item_tree::make_binding_eval_closure::{{closure}}
  35: i_slint_core::properties::alloc_binding_holder::evaluate
  36: i_slint_core::properties::Property<T>::get
  37: <field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get
  38: slint_interpreter::eval::load_property_helper
  39: slint_interpreter::eval::eval_expression
  40: slint_interpreter::eval::eval_expression
  41: slint_interpreter::dynamic_item_tree::make_binding_eval_closure::{{closure}}
  42: i_slint_core::properties::alloc_binding_holder::evaluate
  43: i_slint_core::properties::Property<T>::get
  44: <field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get
  45: slint_interpreter::eval::load_property_helper
  46: slint_interpreter::eval_layout::get_layout_info
  47: slint_interpreter::dynamic_item_tree::layout_info
  48: slint_interpreter::dynamic_item_tree::COMPONENT_BOX_VT::layout_info
  49: core::ops::function::FnOnce::call_once
  50: i_slint_core::properties::alloc_binding_holder::evaluate
  51: i_slint_core::properties::Property<T>::get
  52: core::ops::function::FnOnce::call_once
  53: i_slint_core::properties::alloc_binding_holder::evaluate
  54: i_slint_core::properties::Property<T>::get
  55: core::ops::function::FnOnce::call_once
  56: i_slint_core::properties::alloc_binding_holder::evaluate
  57: i_slint_core::properties::Property<T>::get
  58: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as const_field_offset::PinnedDrop>::drop::VT::layout_info
  59: <i_slint_backend_winit::winitwindowadapter::WinitWindowAdapter as i_slint_core::window::WindowAdapter>::update_window_properties
  60: i_slint_core::window::WindowInner::update_window_properties
  61: <slint_lsp::preview::ui::slint_generatedPreviewUi::PreviewUi as i_slint_core::api::ComponentHandle>::show
  62: slint_lsp::preview::load_preview::{{closure}}::{{closure}}
  63: core::ops::function::FnOnce::call_once{{vtable.shim}}
  64: i_slint_backend_winit::event_loop::EventLoopState::process_event
  65: i_slint_backend_winit::event_loop::EventLoopState::run
  66: <i_slint_backend_winit::Backend as i_slint_core::platform::Platform>::run_event_loop
  67: slint_lsp::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:layouts Related to the layouting and positioning of the elements (mO,bT) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants