@moq/watch: add pull mode to video renderer#1367
@moq/watch: add pull mode to video renderer#1367skirsten wants to merge 1 commit intomoq-dev:mainfrom
Conversation
Adds a `mode: "push" | "pull"` prop on Renderer: - "push" (default, existing behavior): the render effect subscribes to decoder.frame and schedules a single rAF paint per decoded frame. - "pull": runs a self-recursive rAF loop and redraws only when the decoder's current frame differs from what was last drawn. MultiBackend's WebCodecs path now constructs the renderer with `mode: "pull"` so playback runs off the display's vsync rather than the decoder's frame cadence.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe changes introduce a configurable rendering strategy to the WebCodecs rendering pipeline. A new 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
| rafId = requestAnimationFrame(tick); | ||
| }; | ||
|
|
||
| rafId = requestAnimationFrame(tick); |
There was a problem hiding this comment.
I'm not sure if this is worth the compute cost of busy looping requestAnimationFrame if there's no work to be done. Is 120fps versus 144fps that important?
There was a problem hiding this comment.
its 120fps vs the actual video fps (24) so the GPU is actually less busy with the change.
There was a problem hiding this comment.
wait what? how does that work?
With push we should schedule 24 rAF callbacks, while pull should schedule refresh rate rAF callbacks? Are you sure those screenshots are correct?
There was a problem hiding this comment.
Pretty sure, but let me do some actual power testing on my phone or laptop...
I think it has to do with v-sync, but yea, it doesn't really make sense :)
There was a problem hiding this comment.
Okay, I did some more testing and the screenshots are real and there is definitely different magic on chrome's side between them.
But there is actually very little difference in the power draw. I remember this being a real issue in the past though, but that might have been fixed in a chrome or driver update.
Also it seems to depend on the display refresh rate a lot as on a 120 fps display I was getting very different numbers for both.
Anyway, I don't think this is actually needed so we can close this or continue but keep the current push as default?
Btw, both of these run into a issue on 60hz display with 60hz content: It's actually rendering at ~45 fps or so because some frames get unlucky and are being scheduled too late and get overwritten by the next one.
There was a problem hiding this comment.
Yeah, it might be a good idea to schedule the next RAF within the loop, but don't schedule again if the frame didn't change.
For me (on Chrome with 144hz+ monitors) the existing renderer for some reason causes chrome to render the page at 120fps. I checked and the logic is not drawing at that rate so nothing wrong with it.
Instead, if the requestAnimationFrame is done inside another one it apparently does different schedule logic and actually syncs correctly. So the new pull mode causes it to render at the actually video refresh rate...
Let me know what you think and if you are seeing something similar.
Visually they both should be the same so if everything checks out we can also drop the push mode if you want.
Adds a
mode: "push" | "pull"prop on Renderer:MultiBackend's WebCodecs path now constructs the renderer with
mode: "pull"so playback runs off the display's vsync rather than the decoder's frame cadence.