Fix message loop behavior when host callback is cancelled #16407
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.
c2a1a77
New test.
This works on master but would have been broken by #16145.
I verified the test fails on that branch.
3b70481
This is the fix. Again, it doesn't affect master because we don't use
cancelHostCallback
yet. But it fixes the previously added test when combined with #16145. The actual problem isn't related to #16145, we just didn't execute the code path that triggers the bad case until that PR.The problem itself is that
cancelHostCallback
would clear out the callback. Then in the message loop we would see that it'snull
, and exit early. But we wouldn't schedule another one, so the loop would stop. However, the boolean itself would stay true, so next time we schedule something, we'd think the loop was still running. And fail to schedule it. The fix is to reset the boolean.The rAF codepath handles this earlier — in
onAnimate
. But we don't have that entry point in the message loop implementation. So we forgot to do it.22a1287
Just some more tests from #16271 since we're not doing it for now.