-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - tick local executor #6121
Conversation
Can we add an integration test with this PR? This code is clearly tricky to reason about and we were caught totally off-guard by the regression. |
I'm not that acquainted with async to know what a better state would look like tbh. Is it fair to say the issue here is that all AFAIK #4466 was our only option to defer system task spawning, given the constraint that the system executor itself has to be a
I think #4740 would fix this particular point. I don't know if it would also fix the kludginess. I'm not familiar with the details. |
yeah. The issue is that the LocalExecutor needs to be ticked on the main thread and so has to cooperate with everything else the main thread has to do. It might make more sense to tick all the global task pools inside the app runner instead of the scope and add some docs to the TaskPools that "it might be up to the user to tick the local executor on the main thread" for situations where the user isn't using app or using a custom runner. |
2be5a7c
to
f95c417
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on the code quality and docs side. I don't have the expertise on the task side to give a full review, so wait on a second approval from someone who does.
I still want to add a test for ticking the local executors, so please wait on that before merging. |
Added a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like that we need to add a system to tick the local executors, it seems like a last minute monkeypatch. I think this would be easier if we cracked open the internals of async_executor (a la #4740), but this seems to work for now.
@hymm can you rebase this? :) |
I consider the current solution to be the most flexible. There's some ambition to move the bevy runner off of the main thread. This is for multiple reasons including the fact that you can't block (i.e. mutex) on the main thread on wasm. In this case we'll probably need a way of ticking the local executors on the main thread that is not tied to running the scope. This could potentially be a system or some type of main thread runner. In either case the function added in the PR can be called to tick the local executors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's unbreak this for 0.9.
Code LGTM, I like the system based approach much better.
bors r+
# Objective - #4466 broke local tasks running. - Fixes #6120 ## Solution - Add system for ticking local executors on main thread into bevy_core where the tasks pools are initialized. - Add ticking local executors into thread executors ## Changelog - tick all thread local executors in task pool. ## Notes - ~~Not 100% sure about this PR. Ticking the local executor for the main thread in scope feels a little kludgy as it requires users of bevy_tasks to be calling scope periodically for those tasks to make progress.~~ took this out in favor of a system that ticks the local executors.
# Objective - bevyengine#4466 broke local tasks running. - Fixes bevyengine#6120 ## Solution - Add system for ticking local executors on main thread into bevy_core where the tasks pools are initialized. - Add ticking local executors into thread executors ## Changelog - tick all thread local executors in task pool. ## Notes - ~~Not 100% sure about this PR. Ticking the local executor for the main thread in scope feels a little kludgy as it requires users of bevy_tasks to be calling scope periodically for those tasks to make progress.~~ took this out in favor of a system that ticks the local executors.
# Objective - bevyengine#4466 broke local tasks running. - Fixes bevyengine#6120 ## Solution - Add system for ticking local executors on main thread into bevy_core where the tasks pools are initialized. - Add ticking local executors into thread executors ## Changelog - tick all thread local executors in task pool. ## Notes - ~~Not 100% sure about this PR. Ticking the local executor for the main thread in scope feels a little kludgy as it requires users of bevy_tasks to be calling scope periodically for those tasks to make progress.~~ took this out in favor of a system that ticks the local executors.
# Objective - bevyengine#4466 broke local tasks running. - Fixes bevyengine#6120 ## Solution - Add system for ticking local executors on main thread into bevy_core where the tasks pools are initialized. - Add ticking local executors into thread executors ## Changelog - tick all thread local executors in task pool. ## Notes - ~~Not 100% sure about this PR. Ticking the local executor for the main thread in scope feels a little kludgy as it requires users of bevy_tasks to be calling scope periodically for those tasks to make progress.~~ took this out in favor of a system that ticks the local executors.
Objective
Solution
Changelog
Notes
Not 100% sure about this PR. Ticking the local executor for the main thread in scope feels a little kludgy as it requires users of bevy_tasks to be calling scope periodically for those tasks to make progress.took this out in favor of a system that ticks the local executors.