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

repeated scheduled on animationFrameScheduler runs request twice #7226

Closed
gizm0bill opened this issue Mar 20, 2023 · 3 comments
Closed

repeated scheduled on animationFrameScheduler runs request twice #7226

gizm0bill opened this issue Mar 20, 2023 · 3 comments

Comments

@gizm0bill
Copy link

gizm0bill commented Mar 20, 2023

Describe the bug

trying this:

scheduled([0], animationFrameScheduler).pipe( repeat() )

runs at 30fps, meaning the requestAnimationFrame is called twice (tested)

whilst this:

interval(0, animationFrameScheduler)

runs at 60fps

You can notice this behavior here: https://stackblitz.com/edit/rxjs-aksefi?file=index.ts and the corresponding question that raised this bug, here: https://stackoverflow.com/questions/75781770/rxjs-animationframescheduler-is-triggered-only-every-35ms

Is this a bug or by design?

Expected behavior

let last = performance.now();
scheduled([0], animationFrameScheduler).pipe( 
  repeat(), 
  tap(() => {
    const performanceNow = performance.now();
    console.log(performanceNow - last);
    last = performance.now();
  }) )

would expect to print values ~= 16

Reproduction URL

https://stackblitz.com/edit/rxjs-aksefi?file=index.ts

Version

7.8.0

@ajafff
Copy link
Contributor

ajafff commented Mar 20, 2023

not sure if this is a bug, but with the current implementation this behavior is expected (or at least it can be explained):
https://github.com/ReactiveX/rxjs/blob/master/src/internal/scheduled/scheduleArray.ts
For each animationFrame is looks at one index of the array. so at the first animationFrame it emits an item and at the second animationFrame it closes the Observable because there are no more items to emit. here repeat subscribes again so the emit happens at the third animationFrame

@gizm0bill
Copy link
Author

Makes sense @ajafff thanks!
Well I guess it can be closed then?

@jakovljevic-mladen
Copy link
Member

Closing as per OP's comment.

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

No branches or pull requests

3 participants