Skip to content

Conversation

@narodnik
Copy link
Contributor

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.

… the blocking event loop active. (more info below)

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 p2p 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.
@not-fl3
Copy link
Owner

not-fl3 commented Aug 16, 2025

🙏🙏🙏

@not-fl3 not-fl3 merged commit b7b6ac8 into not-fl3:master Aug 16, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants