-
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
interval(0, animationFrameScheduler) emits twice each frame #4972
Comments
It looks more like this is an implementation detail (maybe how the internal browser's timer is refreshed) so it just appears like the events are duplicated. If you use a different method to measure the time between two emissions |
This is misleading then. |
FWIW, the rxjs/src/internal/scheduler/AnimationFrameAction.ts Lines 27 to 28 in 3881723
I've not yet had the time to look at the repro - or at Martin's analysis/comments - but I will try to find the time soon. |
I can confirm the issue, for each frame the observable emits twice. Very confusing, and certainly different from what I was expecting ... |
Just came here to let you know that |
Can you give an example of the proper way to do this? See this StackBlitz (with the None of these counts using RxJS match up with the real |
Yep, this is really strange. I haven't checked it the way you did, just the basic notion that there were 60 not 120 console logs per second gave me that impression. |
Bug Report
Current Behavior
Currently, there seems to be 2 similar ways to organize requestAnimationFrame based observables:
interval(0, animationFrameScheduler)
of(0, animationFrameScheduler).pipe(repeat())
However first approach, using
interval
apparently emits twice each frame. See demo on Stackblitz.Reproduction
https://stackblitz.com/edit/angular-rxjs-animationframe-bug
Expected behavior
interval(0, animationFrameScheduler)
should emit once each frameEnvironment
Additional context/Screenshots
Found those two solutions through search on StackOverflow:
https://stackoverflow.com/a/41818876/2706426
The text was updated successfully, but these errors were encountered: