Skip to content

fix(render): schedule frames on unique vsync slots - #67

Merged
qiin2333 merged 2 commits into
codex/observe-presentation-pacingfrom
codex/vsync-slot-scheduler
Jul 21, 2026
Merged

fix(render): schedule frames on unique vsync slots#67
qiin2333 merged 2 commits into
codex/observe-presentation-pacingfrom
codex/vsync-slot-scheduler

Conversation

@qiin2333

@qiin2333 qiin2333 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

改了啥呀

  • 将 host PTS 理想时间映射到 NativeVSync 的真实槽位
  • 保证每个已提交帧占用唯一槽位,目标时间严格单调
  • 解码突发超出既有余量时在进入 Surface 前丢弃,并等队列排空后再重锚
  • 串行化计划与 RenderOutputBufferAtTime,避免并发回调颠倒提交顺序
  • 增加 queueFull / waitDrain 观测以及 60/90/120 Hz、119.88 NTSC 测试

为啥要改

以前 CATCH_UP 会在 Surface 里已有未来帧时生成更早的目标时间。Surface 又不能倒车,于是这些杂鱼式倒退时间戳会变成同槽覆盖、排队和粘滞。现在只在已提交槽位排空后重锚,不扩大原有节拍余量。

这是基于 #66 的堆叠 PR;#66 继续保持纯观测,方便分别 review。

验证

  • presentation_scheduler_test(含 120 Hz 三帧突发、排空重锚、119.88 NTSC)
  • presentation_observability_test
  • npm run check
  • node hvigorw.js assembleApp --mode project -p product=default -p buildMode=debug --no-daemon --stacktrace

Summary by CodeRabbit

  • 改进

    • 优化了视频帧呈现调度,更准确地结合实际 VSync 时序,提升不同刷新率下的播放稳定性与帧间一致性。
    • 改善了队列繁忙、等待排空、时间不连续及重复时间戳等场景的处理,减少卡顿、异常丢帧和时序偏移。
    • 增强了追帧、重新同步及无效时间戳处理,提升长时间播放的可靠性。
  • 测试

    • 扩展了多种刷新率、队列状态和异常播放场景的验证覆盖。

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@qiin2333, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f49048f2-162c-4c16-ac9e-b30139273e39

📥 Commits

Reviewing files that changed from the base of the PR and between de7509f and a9cb3ec.

📒 Files selected for processing (3)
  • nativelib/src/main/cpp/presentation_scheduler.cpp
  • nativelib/src/main/cpp/presentation_scheduler.h
  • nativelib/src/test/cpp/presentation_scheduler_test.cpp
📝 Walkthrough

Walkthrough

该变更将 PTS 呈现调度改为基于显式 VSync 时序和槽位容量进行计划,新增队列状态与重定锚处理,并让宿主渲染路径记录相关统计;测试覆盖新的多刷新率和异常时序行为。

Changes

精确呈现调度

Layer / File(s) Summary
调度器接口与状态契约
nativelib/src/main/cpp/presentation_scheduler.h
新增 VSync 时序结构、队列相关动作、PlanFrame 重载及槽位调度状态。
槽位调度与计划生成
nativelib/src/main/cpp/presentation_scheduler.cpp
实现时间槽位对齐、队列容量判断、重定锚和基于 VSync 的统一计划决策。
宿主渲染路径与统计
nativelib/src/main/cpp/native_render.h, nativelib/src/main/cpp/native_render.cpp
传入观察到的 VSync 时间,记录队列满、等待 drain 和 API 失败统计,并在处理丢弃计划前释放锁。
VSync 槽位行为验证
nativelib/src/test/cpp/presentation_scheduler_test.cpp
更新测试辅助函数和测试用例,覆盖多刷新率、队列排空、晚帧、不连续及重复 PTS 等行为。

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次改动的核心:按唯一的 vsync 槽位调度帧。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/vsync-slot-scheduler

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qiin2333

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@qiin2333

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@qiin2333
qiin2333 merged commit ddb3938 into codex/observe-presentation-pacing Jul 21, 2026
1 of 2 checks passed
@qiin2333
qiin2333 deleted the codex/vsync-slot-scheduler branch July 21, 2026 08:20
qiin2333 added a commit that referenced this pull request Jul 21, 2026
* fix(stats): improve presentation pacing observability

* fix(stats): bound presentation rate window

* fix(render): schedule frames on unique vsync slots (#67)

* fix(render): schedule frames on unique vsync slots

* fix(render): preserve late-frame rebuffer threshold
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

Successfully merging this pull request may close these issues.

1 participant