-
Notifications
You must be signed in to change notification settings - Fork 3k
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
base: 7.x
Are you sure you want to change the base?
Conversation
Sandbox was not cleaning up correctly and making fail the test that I added.
any update yet? |
@BlueCat0 Unfortunately it seems that no one had the time to review it. 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. |
@pmoleri Your PR is open for quite some time. Has there been another PR which made yours obsolete? Or is this still waiting for a review? I encounter issues with So, is the bug you are trying to fix here still unfixed? |
The issue is actually quite serious, it can affect any Angular app combining animationFrameScheduler with a delay other than 0. In the 7.x branch the files have not been touched in 3 years, so I'm positive that the issue is still there. In master the files have been moved around and the imports changed but the code is exactly the same. |
Hi @benlesh. This PR fixes real bugs and it has tests to confirm the bug and the fix. I made the PR to 7.x, but I could re-target to master and backport later. |
}); | ||
|
||
// This action will execute before the next frame because the delay is less than the one of the frame | ||
animationFrame.schedule(() => { runDelayed = true; }, 1); |
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'm curious the order in which these actions are expected to execute.
Is runFirst
expected to be true when runDelayed
is set to true? e.g.:
animationFrame.schedule(() => { runDelayed = true; }, 1); | |
animationFrame.schedule(() => { | |
if (!runFirst) { | |
done(new Error('First action did not run')); | |
} else { | |
runDelayed = true; | |
} | |
}, 1); |
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.
No, it's the opposite. The action queued with a delay smaller than animationFrame runs first.
That's how animationFrameScheduler is implemented, actions with delay other than zero are scheduled purely based on time and not actual animation frames.
I'll push a change to make it more clear.
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.
There. I pushed the change. Now each scheduled action asserts the previous one. Instead of having everything in the last one.
Make test assert order more clear
animationFrameScheduler
has a few issues that makes it miss tasks and even start accumulating tasks that never get flushed._scheduled
even though current id might be a different one.Related issues:
already fixed but similar cause
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:
_scheduled
one.