Open mkrasnitski opened 2 months ago
The validation error is from desynchronized draw and resize. Resize is deferred by winit-input-helper
, but drawing is not.
It can be fixed by reordering these operations. E.g. by moving the drawing code after the resize, but before the world.update()
call. Or alternatively and preferably, move the resize out of the input.update()
guard and use the normal winit
event matching instead.
Sigh. These are some skeletons in the closet. The history here is sort of documented in https://github.com/parasyte/pixels/issues/270#issuecomment-1092627678.
I ended up matching on the event for RedrawRequested
separately from using input.update()
's return value for some of the reasons described there. We kind of got away with it, but these events should not be deferred.
Deferring these events causes problems like the resize looking horrible while the user drags the window frame around. The intermediate frame gets stretched and warped. The right way to handle resize will correctly redraw every frame while the resize is in progress. And doing that means no deferral of resize and redraw events.
And yeah, deferring events is what you are expected to do with winit-input-helper
: https://github.com/rukai/winit_input_helper/blob/106e033c718ccfb346866c054d23025666ae13ae/examples/example.rs#L33-L35
So, it's probably time for it to go.
I'm also completely misremembering how it ended up that RedrawRequested
is treated differently from the rest of the event handling. Because this was there since the beginning with a salient comment:
All of the examples inherited it.
imgui-wgpu-rs now supports wgpu 0.19 and winit 0.29, but only on the git HEAD. A release hasn't been cut yet so keeping this as draft for now. Also, resizing the window now crashes the app with the following error:
I figured this PR would be a good place to track this while the root cause is figured out.