Repository navigation
fix(preview): publish preview frames per fps slot, not per rounded-up millisecond - #347
Conversation
should_publish_preview_frame turned a target rate into a whole millisecond interval rounded up: 30 fps became 34 ms. The render loop delivers frames about 33 ms apart, so the gate refused every other frame and the preview bus carried 15 to 19 fps to anyone asking for 30. The Remote live preview's acceptance lane measured exactly that on a 480 px VP8 track whose encoder was keeping pace. The gate now publishes once per 1/fps slot of the uptime clock: a frame publishes when it lands in a later slot than the last published frame. Slots hand out the target rate on average, absorb render jitter in either direction, and still cap a fast loop at a slow target (a 60 fps loop against 2 fps publishes twice a second). The slot index is fixed point so the comparison stays exact past u32 milliseconds of uptime, which the existing test now covers from a slot boundary. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017QqD4e2C7kLCBtZBEfJyTx
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughPreview publication now uses fixed-point uptime slots instead of a rounded-up millisecond interval. Tests cover long uptime, 30 fps publication, and a 2 fps cap on a 60 fps loop. ChangesPreview Publication Cadence
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to This change fixes the preview frame cadence so 30 fps subscribers receive the target rate. No actionable merge risk was identified. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Comment |
The preview frame gate rounded a target rate up to a whole-millisecond interval, so a 30 fps request became a 34 ms gate. The render loop spaces frames about 33 ms apart, which means every other frame failed the gate and preview subscribers asking for 30 fps received 15 to 19. The Remote live preview's acceptance lane measured exactly that on a 480 px VP8 track whose encoder was keeping pace with what it was given.
🛠️ How it works
should_publish_preview_framenow publishes once per 1/fps slot of the uptime clock: a frame publishes when it lands in a later slot than the last published frame. Slots hand out the target rate on average, absorb render jitter in either direction, and still cap a fast loop at a slow target. The slot index is fixed point, so the comparison stays exact past u32 milliseconds of uptime.🧪 Validation
cargo test --locked -p hypercolor-daemon --lib render_thread::pipeline_runtimecargo fmt --check,cargo clippy -p hypercolor-daemon --lib -D warningsThe uptime test now starts its clock on a slot boundary so its two assertions straddle exactly one slot; the behavior it protects is unchanged.
🤖 Generated with Claude Code
https://claude.ai/code/session_017QqD4e2C7kLCBtZBEfJyTx
Summary by CodeRabbit