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

Flex layout panics when forced to too small place #1619

Closed
2 tasks done
Jaakkonen opened this issue Dec 23, 2022 · 3 comments · Fixed by #1637
Closed
2 tasks done

Flex layout panics when forced to too small place #1619

Jaakkonen opened this issue Dec 23, 2022 · 3 comments · Fixed by #1637
Labels
bug Something isn't working layout
Milestone

Comments

@Jaakkonen
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

When moving a window with large components to too small place in a tiling window manager (in this case Sway), flex container may panic with window size being too small.

What is the expected behavior?

The expected behavior is for the application to draw for example top-left corner of the application to the restricted space and not to crash (allowing the user to resize the app)

Version

master

Operative System

Linux

Do you have any log output?

RUST_BACKTRACE=1 cargo run --features iced/glow --package game_of_life                       
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/game_of_life`
thread 'main' panicked at 'assertion failed: min <= max', /rustc/b569c9dc57ee22b6ff94563af856909763dfa24b/library/core/src/num/f32.rs:1394:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/b569c9dc57ee22b6ff94563af856909763dfa24b/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/b569c9dc57ee22b6ff94563af856909763dfa24b/library/core/src/panicking.rs:64:14
   2: core::panicking::panic
             at /rustc/b569c9dc57ee22b6ff94563af856909763dfa24b/library/core/src/panicking.rs:111:5
   3: core::f32::<impl f32>::clamp
             at /rustc/b569c9dc57ee22b6ff94563af856909763dfa24b/library/core/src/num/f32.rs:1394:9
   4: iced_native::layout::limits::Limits::resolve
             at ./native/src/layout/limits.rs:158:13
   5: <iced_native::widget::text::Text<Renderer> as iced_native::widget::Widget<Message,Renderer>>::layout
             at ./native/src/widget/text.rs:144:20
   6: iced_native::layout::flex::resolve
             at ./native/src/layout/flex.rs:135:26
   7: <iced_native::widget::row::Row<Message,Renderer> as iced_native::widget::Widget<Message,Renderer>>::layout
             at ./native/src/widget/row.rs:122:9
   8: iced_native::layout::flex::resolve
             at ./native/src/layout/flex.rs:184:26
   9: <iced_native::widget::row::Row<Message,Renderer> as iced_native::widget::Widget<Message,Renderer>>::layout
             at ./native/src/widget/row.rs:122:9
  10: iced_native::layout::flex::resolve
             at ./native/src/layout/flex.rs:135:26
  11: <iced_native::widget::column::Column<Message,Renderer> as iced_native::widget::Widget<Message,Renderer>>::layout
             at ./native/src/widget/column.rs:135:9
  12: <iced_native::widget::container::Container<Message,Renderer> as iced_native::widget::Widget<Message,Renderer>>::layout::{{closure}}
             at ./native/src/widget/container.rs:163:17
  13: iced_native::widget::container::layout
             at ./native/src/widget/container.rs:300:23
  14: <iced_native::widget::container::Container<Message,Renderer> as iced_native::widget::Widget<Message,Renderer>>::layout
             at ./native/src/widget/container.rs:152:9
  15: <iced_graphics::renderer::Renderer<B,T> as iced_native::renderer::Renderer>::layout
             at ./graphics/src/renderer.rs:61:22
  16: iced_native::user_interface::UserInterface<Message,Renderer>::build
             at ./native/src/user_interface.rs:103:13
  17: iced_native::user_interface::UserInterface<Message,Renderer>::relayout
             at ./native/src/user_interface.rs:520:9
  18: iced_glutin::application::run_instance::{{closure}}
             at ./glutin/src/application.rs:355:25
  19: iced_glutin::application::run::{{closure}}
             at ./glutin/src/application.rs:167:24
  20: winit::platform_impl::platform::sticky_exit_callback
             at /home/jaakko/.local/share/cargo/git/checkouts/winit-57d3141eaf559308/9404575/src/platform_impl/linux/mod.rs:849:9
  21: winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run_return
             at /home/jaakko/.local/share/cargo/git/checkouts/winit-57d3141eaf559308/9404575/src/platform_impl/linux/wayland/event_loop/mod.rs:529:21
  22: winit::platform_impl::platform::EventLoop<T>::run_return
             at /home/jaakko/.local/share/cargo/git/checkouts/winit-57d3141eaf559308/9404575/src/platform_impl/linux/mod.rs:748:56
  23: <winit::event_loop::EventLoop<T> as winit::platform::run_return::EventLoopExtRunReturn>::run_return
             at /home/jaakko/.local/share/cargo/git/checkouts/winit-57d3141eaf559308/9404575/src/platform/run_return.rs:62:9
  24: iced_glutin::application::run
             at ./glutin/src/application.rs:142:13
  25: iced::application::Application::run
             at ./src/application.rs:216:12
  26: game_of_life::main
             at ./examples/game_of_life/src/main.rs:23:5
  27: core::ops::function::FnOnce::call_once
             at /rustc/b569c9dc57ee22b6ff94563af856909763dfa24b/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@Jaakkonen Jaakkonen added the bug Something isn't working label Dec 23, 2022
@alexxbb
Copy link

alexxbb commented Dec 24, 2022

Same issue with the geometry example. It panics right right away without even starting.

@udoprog
Copy link

udoprog commented Jan 3, 2023

I encountered this as well, here's a minimal repro I put together for my own report. This only crashes if the padding of the row is large enough to (presumably) overlap with the horizontal rule where the crashing calculation happens when the application surface becomes too small.

Note that this also happens reliably when the application is minimized on Windows:

use iced::executor;
use iced::widget::{horizontal_rule, Column};
use iced::{Application, Command, Element, Settings, Theme};

pub fn main() -> iced::Result {
    LayoutPanic::run(Settings {
        ..Settings::default()
    })
}

struct LayoutPanic;

impl Application for LayoutPanic {
    type Executor = executor::Default;
    type Message = ();
    type Theme = Theme;
    type Flags = ();

    fn new(_flags: ()) -> (Self, Command<()>) {
        (LayoutPanic, Command::none())
    }

    fn title(&self) -> String {
        String::from("Layout Panic - Iced")
    }

    fn update(&mut self, _: ()) -> Command<()> {
        Command::none()
    }

    fn view(&self) -> Element<()> {
        Column::new()
            .push(Column::new().padding(20))
            .push(horizontal_rule(1))
            .into()
    }
}

@hecrj
Copy link
Member

hecrj commented Jan 5, 2023

This is a bug introduced by #1611.

I just opened #1637 that should fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working layout
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants