Skip to content
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

fix(animationFrameScheduler): some tasks are never flushed and sometimes it breaks completely #7444

Open
wants to merge 4 commits into
base: 7.x
Choose a base branch
from

Conversation

pmoleri
Copy link

@pmoleri pmoleri commented Feb 20, 2024

animationFrameScheduler has a few issues that makes it miss tasks and even start accumulating tasks that never get flushed.

  • It's clearing the _scheduled in every flush, but some of the flushes are not for the next scheduled frame, they're regular async timeouts.
  • because it might be picking the incorrect flushId it may flush tasks before the next frame
  • after flushing and recycling the id it's clearing the _scheduled even though current id might be a different one.

Related issues:

Failing tests are included in a independent commit and then fixed.

Note:
The changes could also be ported to AsapScheduler for consistency (also I think it's more clear).
However, I couldn't reproduce the issues there because:

  • AsapScheduler already contains one of the fixes
  • In AsapScheduler I couldn't schedule a task to happen before the _scheduled one.

@pmoleri
Copy link
Author

pmoleri commented Feb 29, 2024

Hi @benlesh. I noticed that you fixed #7196 for asapScheduler, but animationFrameScheduler has similar issue, and worse even (reason explained in this PR description).
Any chance that you can review this PR? It also includes tests that make it fail without the fix.

@BlueCat0
Copy link

BlueCat0 commented Sep 4, 2024

any update yet?

@pmoleri
Copy link
Author

pmoleri commented Sep 4, 2024

@BlueCat0 Unfortunately it seems that no one had the time to review it.
Once you understand the code (which takes a while) the bug is pretty clear and the resolution too.

To avoid the bug altogether, never use animationFrameScheduler with a delay, you can use the asyncScheduler for that purpose. In fact they would behave exactly the same, as animationFrameScheduler doesn't really schedule into a frame when delay is used.

Note that using animationFrameScheduler with a delay in one place may impact in a different place.

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