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 and asapScheduler no longer executing actions #6889

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ajafff
Copy link
Contributor

@ajafff ajafff commented Mar 14, 2022

Description:

AnimationFrameAction and AsapAction's recycleAsyncId should only reset scheduler_scheduled if it's the same id we are currently recycling. This fixes the issue described in #6854 where actions scheduled from another action have already set scheduler._scheduled, which is then cleared when the currently executing action is done.
This works because there are at most 2 schedules for these schedulers: the currently executing one and the next schedule. This also means we no longer cancelAnimationFrame/clearImmediate the current schedule after its last action is done (which does nothing for correctness, but avoid unnecessary work).

Related issue (if exists):
Fixes #6854

result.push('work');
if (reschedule) {
asapScheduler.schedule(() => result.push('task 1'));
asapScheduler.schedule(() => result.push('task 2'));
Copy link
Member

@benlesh benlesh Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an assertion right here to make sure that the above tasks didn't execute synchronously in this spot? Basically, just check to make sure results haven't changed yet. It's not so much that I think they did, it's that I want to make sure they're "scheduled" and don't just happen to mimic the proper outcome by virtue of when we checked.

Please do the same for the other test? Thanks, @ajafff!

Otherwise, this looks great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benlesh could you please review it again? Can't upgrade above 7.4.0 due to this problem.

@pmoleri
Copy link

pmoleri commented Mar 7, 2024

@benlesh

This is a serious bug and produces all kind of issues on applications that use animationFrameScheduler.
I didn't notice about this PR (and created a similar one myself), almost 2 years later! !7444

Can we please review one of them and merge it?

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.

animationFrameScheduler incorrect behavior
4 participants