Skip to content

panic in ScrollArea in egui 0.32.0 #7362

@hydra

Description

@hydra

Describe the bug
When clicking a scroll area's resize handle, I get an instant panic caused by a debug assertion.

The scroll area is the one belonging to an egui_extra table, and not one that I created.

See also #4478 and #5216.

To Reproduce
Steps to reproduce the behavior:

  1. Run MakerPnP planner_egui @ rev d3f1c30718da433df8c485e01d88d3258ef802ae
  2. Open a project
  3. Double click the unit assignments in the treeview.
  4. Left click the scrollbar.
  5. Observe panic.

Screenshots

Image

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: N/A

Smartphone (please complete the following information):
N/A

Additional context

I added debug info to scroll_area.rs:

let new_handle_top = pointer_pos[d] - *scroll_start_offset_from_top_left;
                println!("new_handle_top: {:?}", new_handle_top);
                println!("scroll_bar_rect: {:?}", scroll_bar_rect);

                let from = scroll_bar_rect.min[d]..=(scroll_bar_rect.max[d] - handle_rect.size()[d]);
                println!("from: {:?}", from);
                state.offset[d] = remap(
                    new_handle_top,
                    from,
                    0.0..=max_offset[d],
                );

the output is:

new_handle_top: 332.0
scroll_bar_rect: [[481.0 332.0] - [1257.0 372.0]]
from: 332.0..=332.0
and the panic is:

thread 'main' panicked at D:\Users\Hydra\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\emath-0.32.0\src\lib.rs:152:5:
from.start() and from.end() should not be equal

Here's a link to the source:

https://github.com/MakerPnP/makerpnp/blob/b7240c367fd49c5440626e5c7a1d480a4a70807f/crates/planner_gui_egui/src/project/tabs/unit_assignments_tab.rs#L383-L463

Additionally, as per the screenshot, there are two extremely similar tables in the UI, the second one does not panic, the debug output when it is clicked is:

new_handle_top: 455.0
scroll_bar_rect: [[533.0 455.0] - [1475.0 495.0]]
from: 455.0..=481.99188

if you resize the second one, so that all the elements are visible, and then click it, it too panics, like this:

Image
new_handle_top: 455.0
scroll_bar_rect: [[533.0 455.0] - [1475.0 600.0]]
from: 455.0..=455.0

thread 'main' panicked at D:\Users\Hydra\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\emath-0.32.0\src\lib.rs:152:5:
from.start() and from.end() should not be equal

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions