iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.28k stars 1.13k forks source link

PaneGrid resize may freeze the application in edge cases #1983

Open spcan opened 1 year ago

spcan commented 1 year ago

Is there an existing issue for this?

Is this issue related to iced?

What happened?

I have run into an error in which the pane grid resize events can cause freezes or crashes in the application in edge cases.

Specifically, I have been most successful reproducing it when resizing a pane grid and ,at the stopping point of the resize, the line or the mouse pointer is over a button or a text input (see example image below). This sometimes causes a freeze of the application or a full crash. If it freezes, changing the size of the window sometimes fixes the issue after some visual glitches. If not, the only thing that works is closing (normal closing still works).

image

I have found a workaround by filtering the resize events by the ratio and limiting the resize events to bigger than 0.1 and less than 0.9 (non inclusive, using those values can crash still). See the example below.

fn update(&mut self, event: Event) -> Command<Event> {
    match event {
        Event::PaneGridResize( resize ) => self.panes.resize(&resize.split, resize.ratio.clamp(0.25, 0.75)),
        ...
    }
    ...
}

What is the expected behavior?

The application not crashing or freezing.

Version

crates.io release

Operating System

Linux

Do you have any log output?

None
hecrj commented 1 year ago

I suspect #1996 may fix this.