Skip to content

Change popup memory to be per-viewport #6753

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

mkalte666
Copy link
Contributor

Starting with 77244cd the popup open-state is cleaned up per memory pass.

This becomes problematic for implementations that share memory between viewports (i.e. all of them, as far as i understand it), because each viewport gets a context pass, and thus a memory pass, which cleans out popup open state.

To illustrate my issue, i have modifed the multiple viewport example to include a popup menu for the labels: https://gist.github.com/mkalte666/4ecd6b658003df4c6d532ae2060c7595 (changes not included in this pr).

Then, when i try to use the popups, i get this:

before.mp4

Immediate viewports just break popup handling in general, while deferred viewports kinda work, or dont. In this example ill be honest, it kind of still did, sometimes. In my more complex app with multiple viewports (where i encountered this first) it also just broke - even when just showing root and one nother. Probably to do with the order wgpu vs glow draws the viewports? Im not sure. In any case:

This commit adds Memory::popup (now Memory::popups) to the per-viewport state of memory, including viewport aware cleanup, and adding it to the list of things cleaned if a viewport goes away.

This results in the expected behavior:

after.mp4

I will note that with this, changing focus does not cause a popup to be closed, which is consistent with current behavior on a single app.

Hope this helps

~Malte

Starting with 77244cd (emilk@77244cd) the popup open-state is cleaned up per memory pass.

This becomes for implementations that share memory between viewports,
because each viewport gets a context pass, and thus a memory pass, which
cleans out popup open state.

This commit adds `Memory::popup` (now `Memory::popups`) to the
per-viewport state of memory, including viewport aware cleanup, and
adding it to the list of things cleaned if a viewport goes away.
Copy link

Preview available at https://egui-pr-preview.github.io/pr/6753-popupmemoryperviewport
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

Copy link
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think a similar bug could also exsit for menus, where I also do some cleanup if the memory wasn't shown for a frame. But it's implemented using the frame count there, so maybe it's fine.

@lucasmerlin lucasmerlin added bug Something is broken egui labels Apr 16, 2025
@lucasmerlin lucasmerlin merged commit 114460c into emilk:master Apr 22, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants