Skip to content

fix(render): preserve PTS burst frames - #71

Merged
qiin2333 merged 1 commit into
masterfrom
codex/remove-pts-queue-cap
Jul 22, 2026
Merged

fix(render): preserve PTS burst frames#71
qiin2333 merged 1 commit into
masterfrom
codex/remove-pts-queue-cap

Conversation

@qiin2333

@qiin2333 qiin2333 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

改了啥呀

  • 删除 PTS 调度器的固定未来槽位上限,不再因为第 4 个或第 5 个 burst 帧超出软件预算就主动释放
  • 保留一帧一个 VSync 槽的节奏整形,短时硬解 burst 会排进连续槽位,平均输出恢复后自然排空
  • 删除 QUEUE_FULL、重锚重试状态和对应统计;有效 PTS 只调度,只有无效 PTS 才由调度器拒绝
  • 保留 2 ms 常态提交余量、晚到相移、严重晚到重锚,以及 maxLead / maxQueueSlots 积压观测
  • 新增 60/90/120 FPS burst 和连续 120 轮五帧 burst 回归,确认不丢帧且队列不会逐轮增长

为啥要改

硬解输出经常成批回调,但平均帧率仍与显示刷新率一致。旧的三槽上限会把第 4 帧直接变成 QUEUE_FULL,这个杂鱼容量判断把可自然排空的瞬时 burst 误判成持续积压,所以清掉等待状态后用户仍能看到同样的基础掉帧。现在让 RenderService 接收完整的连续 PTS 槽位,客户端不再抢着替系统丢有效帧。

这版刻意保留槽位整形,只移除硬容量丢帧,便于设备侧单独验证根因。若生产速率长期高于显示速率,maxLeadmaxQueueSlots 会直接暴露积压,而不是被主动丢帧掩盖。

验证

  • c++ -std=c++17 -Wall -Wextra -Werror -I nativelib/src/main/cpp nativelib/src/main/cpp/presentation_scheduler.cpp nativelib/src/test/cpp/presentation_scheduler_test.cpp -o /tmp/moonlight-presentation-scheduler-test && /tmp/moonlight-presentation-scheduler-test: passed
  • c++ -std=c++17 -Wall -Wextra -Werror -I nativelib/src/main/cpp nativelib/src/main/cpp/presentation_diagnostics.cpp nativelib/src/main/cpp/rolling_frame_rate.cpp nativelib/src/test/cpp/presentation_observability_test.cpp -o /tmp/moonlight-presentation-observability-test && /tmp/moonlight-presentation-observability-test: passed
  • DEVECO_SDK_HOME=/Users/mac/ohos-sdk-cache/6.1-Release-mac/sdk-ci-shape JAVA_HOME=/Applications/DevEco-Studio.app/Contents/jbr/Contents/Home PATH=/Applications/DevEco-Studio.app/Contents/jbr/Contents/Home/bin:$PATH node hvigorw.js assembleApp --mode project -p product=default -p buildMode=debug --no-daemon: BUILD SUCCESSFUL
  • git diff --check: passed

Summary by CodeRabbit

  • 改进
    • 优化帧呈现调度,减少突发帧场景下的不必要丢帧。
    • 改善 60fps、90fps 和 120fps 内容的目标时间连续性与调度稳定性。
    • 优化重复时间戳帧的重新锚定处理,提升后续帧恢复效果。
    • 精简呈现统计信息,改进主机节奏模式下的性能日志。

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7274b18f-a164-489e-acc9-fc2455462a60

📥 Commits

Reviewing files that changed from the base of the PR and between b0bdf22 and ed8961a.

📒 Files selected for processing (5)
  • nativelib/src/main/cpp/native_render.cpp
  • nativelib/src/main/cpp/native_render.h
  • nativelib/src/main/cpp/presentation_scheduler.cpp
  • nativelib/src/main/cpp/presentation_scheduler.h
  • nativelib/src/test/cpp/presentation_scheduler_test.cpp
💤 Files with no reviewable changes (3)
  • nativelib/src/main/cpp/native_render.h
  • nativelib/src/main/cpp/presentation_scheduler.h
  • nativelib/src/main/cpp/presentation_scheduler.cpp

📝 Walkthrough

Walkthrough

Changes

队列满路径移除

Layer / File(s) Summary
调度器删除队列满与重锚重试路径
nativelib/src/main/cpp/presentation_scheduler.*
移除 QUEUE_FULL、额外队列槽位计算及重锚重试状态和控制流。
Host-paced 统计移除队列满计数
nativelib/src/main/cpp/native_render.*
删除 preciseQueueFullCount_,并将日志字段调整为 maxQueueSlots
调度器测试改为验证帧保留
nativelib/src/test/cpp/presentation_scheduler_test.cpp
更新 burst 与重复 PTS 测试,验证帧保留、目标时间连续和重锚事件。

Estimated code review effort: 3 (Moderate) | ~25 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 标题准确概括了本次修复的核心:保留 PTS 突发帧,不再因队列满而丢帧。
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/remove-pts-queue-cap

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
qiin2333 merged commit 5859bb6 into master Jul 22, 2026
2 checks passed
@qiin2333
qiin2333 deleted the codex/remove-pts-queue-cap branch July 22, 2026 10:36
qiin2333 added a commit that referenced this pull request Jul 22, 2026
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