Ensure WinitUserEvent::WakeUp trigger app update#23957
Draft
rmaj91 wants to merge 2 commits intobevyengine:mainfrom
Draft
Ensure WinitUserEvent::WakeUp trigger app update#23957rmaj91 wants to merge 2 commits intobevyengine:mainfrom
rmaj91 wants to merge 2 commits intobevyengine:mainfrom
Conversation
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
andriyDev
reviewed
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This PR targets browser unfocused tab throttling issue. Currently bevy window event loop depends on the request animation frame (LINK) which doesn't work on the unfocused browser tabs.
When brower stops rendering also bevy stops calling app.update() which effectively stops all the systems and makes bevy wasm not usable in apps that require keeping networking alive or somehow requires processing in the background.
more info:
#13486
#13366
ISSUE
Actual app.update() is called here: LINK
snippet:
App update depends on two variables:
all_visiblewhich is not relevant in this case.And on
ran_update_since_last_redrawwhich is the key here.App.update() only happens when
ran_update_since_last_redrawis set to false, false value is set HERE as reaction on WindowEvent::RedrawRequested which is emitted whenThe application has explicitly requested a redraw via [Window::request_redraw].LINK.SOLUTION
WinitUserEvent::WakeUp sets flag
ran_update_since_last_redraw = false. This makes wake up event not only request redraw but also hints (WinitSettings update mode it's still respected here) event loop to call app.update()Alternative solution
Can set this flag to false as RequestRedraw event reaction LINK
Also can consider introducing another flag to control update.
Testing
Did manual testing, I was able to wake up app and print logs in the unfocused tab.
This is only a proposal, and I would be grateful for any feedback or help.
Edit: I believe this is right solution for this problem. Final implementation details can vary but it seems it nicely integrates into winit_plugin loop.