Fix intermittent drag-and-drop freezing on Windows #19772
+5
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Fixes #19030.
Since Bevy 0.15.3, there has been a bug on Windows where drag-and-drop will occasionally freeze the application where the only fix is to resize the window.
Solution
This adds a check for any window events being received when determining if a redraw is requested—specifically on Windows. A drag-and-drop event sets the
self.window_event_received
flag to true.For non-Windows platforms,
self.redraw_requested(event_loop)
is always called, but the Windows-specific branch has checks that for some reason sometimes don't properly handle a drag-and-drop event (and maybe other types of events?).I also tried replacing all of the
WINIT_WINDOWS.with_borrow(...)
with justself.redraw_requested(event_loop)
, and that fixes the problem too (and then matches the non-Windows behavior), but I assume the Windows-specific checks are otherwise there for a reason.Note: I'm not sure why the freeze only sometimes occurred. This change fixes the specific drag-and-drop freeze problem, but there may be some sort of deeper bug/issue causing the strange behavior in the first place.
Testing
I could replicate the intermittent freeze on Windows 11 in the drag-and-drop example, and this change seems to fully fix that problem.
Showcase
Here is the existing intermittent freeze in action before the fix. While there is nothing in the drag-and-drop example window, the whole application is completely frozen until the window is resized.
Bevy.Drag.Drop.Bug_20250621.mp4