-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
eframe with wgpu panics when unloading texture in same frame as rendering it #5224
Comments
Hi! That definitely sounds like a bug. I assume, if you run the example code with the gl backend that it works successfully? Moving the free_texture calls below the submit sounds like a reasonable fix, would you like to open a PR? |
The example runs just fine with egui-glow. |
…erer (emilk#5226) * Closes emilk#5224 I'm unfamiliar with wgpu, so I'd like someone to confirm, that calling `wgpu::Texture` _after_ `wgpu::Queue::submit` is in fact the right thing to do. --------- Co-authored-by: Andreas Reich <r_andreas2@web.de>
Thanks for fixing this. I came across this issue in a different way. This issue was causing crashes that were also somehow related to the state of a grid. See attached for MWE if anyone else comes across this. This commit fixed my issue. |
Describe the bug
When using eframe with the wgpu renderer the program may panic, if you drop a
TextureHandle
in the same frame as it is used for rendering. The panic happens whenegui_wgpu::winit::Painter::paint_and_update_textures
submits thewgpu::Queue
in crates/egui-wgpu/src/winit.rs:688. The unloading of the texture happens before that in line 673. I barely understand any of the code in that function, but if I just move the texture unloading to after the queue submitting (e.g. line 693), my code doesn't crash anymore.If this is the correct fix, this means that destroying a texture is not a queued command. I tried to find out about that, but only found:
Texture::destroy
: "Destroy the associated native resources as soon as possible."If this is not the correct fix, there may be a bug in wgpu itself.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The example picture should be shown in a window and the code should not panic.
Additional context
I encountered this issue in a project in which I want to display the image files in a folder as described in #5200. Since I may not be able to hold all images in memory, I unload them regularly depending on the selection of the user. If I scroll through the images too quickly, the crash occurs.
In my project the crash happens quite randomly, but with the example program above I can reliably produce a panic on frame 1. I'm not sure if this will work on every machine though.
The text was updated successfully, but these errors were encountered: