rerun-io / rerun

Visualize streams of multimodal data. Free, fast, easy to use, and simple to integrate. Built in Rust.
https://rerun.io/
Apache License 2.0
6.59k stars 334 forks source link

Context menu & hover box width is sometimes too narrow #6801

Open Wumpf opened 4 months ago

Wumpf commented 4 months ago

I'm not sure how I exactly got into this state, but the context appeared sometimes wide and sometimes narrow depending on the item:

https://github.com/rerun-io/rerun/assets/1220815/14d6b66b-7a76-4cf1-afbd-f4d00c7076a0

Once (not captured on video) I got an even narrower context menu which had only space for 1-2 characters.

(0.17rc2 @ Windows)

Wumpf commented 4 months ago

The same seems to happen with tooltips image

emilk commented 4 months ago

There's nothing random in your video - it seems to depend 100% on which element was clicked

Wumpf commented 4 months ago

Not in the video, itself but

emilk commented 4 months ago

I could see this bug happening if the context menu changes content over time. If a given context menu is narrow the first time it is shown, it will remember this narrowness and then in the future break new elements to this width.

If this is indeed the problem, there are few different fixes to consider: A) change the Id of the context menu based on its content B) remove line wrapping from context menus

emilk commented 1 month ago

I suspect this only happens when pixels-per-point is non-integer, due to some rounding problem, perhaps same problem as in https://github.com/emilk/egui/issues/5084.

The idea would be: we lay out the contents of the popup with a wide max_size/wrap-width. The text does not wrap, and the non-wrapped size of the text is reported up the Ui chain and the final size is then stored for the Area. This size is then set as the max_size on subsequent frames, but due to some rounding error, the text will now wrap, despite the width presumably being exactly the width where it does not need to wrap.

I've tried to avoid this issue in epaint/egui by rounding text widths up to the nearest integer point width, but obviously there is still some bug somewhere. I'm investigating…

emilk commented 1 month ago

I think the original issue with shrinking menus was mostly solved by

But for menus with dynamic content we need a proper fix for:

The tooltip issue is a separate one: