android: allow calling window::schedule_update() from any thread with the blocking event loop active #578
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.
Android with the non blocking event loop, uses mpsc rx.try_recv() repeatedly which drastically reduces the battery (revealed during my testing). The solution is then to use the blocking event loop, but due to the current design where requests are a separate queue, then calling schedule_update() will only work when the main queue has already been interrupted.
The reason calling schedule_update() inside events alone is insufficient is for async events like notifications such as connection status indicator which varies regardless of user action.
The solution then for android is to merge both these queues together. Since NativeDisplayData.native_requests() is a queue, we replace this with a callback instead. Then each native module can specify whichever logic they want to pass in requests. For android merging the queues together solves the issue.
For now I left Mac, Win, iOS and Linux untouched, but will gradually add these in since the goal is also to be able to use non blocking event loop on laptops and save battery as well.