fix(haptics): expire stale audio output - #84
Conversation
|
Warning Review limit reached
Next review available in: 51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Changes持续输出看门狗
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@entry/src/main/ets/service/AudioVibrationService.ets`:
- Around line 219-222: 在 renderFrame 的所有提前返回路径(包括幅度去抖和节流判断)之前,针对 continuous 达到
AudioVibrationService.MINIMUM_INTENSITY 且 isDeviceSourceActive 或
isUsbSourceActive 为真的有效持续帧调用
armContinuousOutputWatchdog();保留现有提交路径中的调用,以覆盖首次输出场景。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 47473993-8c41-4a4a-b8f6-2b80d201defa
📒 Files selected for processing (1)
entry/src/main/ets/service/AudioVibrationService.ets
| if (continuous >= AudioVibrationService.MINIMUM_INTENSITY && | ||
| (this.isDeviceSourceActive || this.isUsbSourceActive)) { | ||
| this.armContinuousOutputWatchdog(); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
稳定持续输出会在 1200 ms 后被误停。
renderFrame 在 Line 166-170 的幅度去抖、Line 162-165 或 Line 179 的节流路径中会提前返回,因此稳定的持续输出帧不会执行这里的 armContinuousOutputWatchdog()。结果是看门狗只在首次提交后启动,约 1200 ms 后便调用 stopAll(),即使有效持续帧仍在到达也会清除振动。
请在这些提前返回之前,针对强度达到最低阈值且已有活动来源的有效持续帧刷新看门狗;保留此处调用以覆盖首次提交输出的场景。
建议修复
if (!hasTransient &&
selected < AudioVibrationService.MINIMUM_INTENSITY) {
if (continuousChanged || hasStop) this.stopAll();
return;
}
+ if (continuous >= AudioVibrationService.MINIMUM_INTENSITY &&
+ (this.isDeviceSourceActive || this.isUsbSourceActive)) {
+ this.armContinuousOutputWatchdog();
+ }
+
const now = Date.now();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (continuous >= AudioVibrationService.MINIMUM_INTENSITY && | |
| (this.isDeviceSourceActive || this.isUsbSourceActive)) { | |
| this.armContinuousOutputWatchdog(); | |
| } | |
| if (!hasTransient && | |
| selected < AudioVibrationService.MINIMUM_INTENSITY) { | |
| if (continuousChanged || hasStop) this.stopAll(); | |
| return; | |
| } | |
| if (continuous >= AudioVibrationService.MINIMUM_INTENSITY && | |
| (this.isDeviceSourceActive || this.isUsbSourceActive)) { | |
| this.armContinuousOutputWatchdog(); | |
| } | |
| const now = Date.now(); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@entry/src/main/ets/service/AudioVibrationService.ets` around lines 219 - 222,
在 renderFrame 的所有提前返回路径(包括幅度去抖和节流判断)之前,针对 continuous 达到
AudioVibrationService.MINIMUM_INTENSITY 且 isDeviceSourceActive 或
isUsbSourceActive 为真的有效持续帧调用
armContinuousOutputWatchdog();保留现有提交路径中的调用,以覆盖首次输出场景。
改了啥呀
为啥要改
游戏模式静音或信号中断时,USB 手柄可能一直保持最后一次电机值,部分机身马达也可能没有按预期自然结束;此前只能等下一帧信号触发重算。现在给这种赖着不走的杂鱼残留状态加一道输出层兜底,不改 SDK 节拍、强度或场景算法。
验证
npm run checknode hvigorw.js assembleHap --mode module -p module=entry@default -p product=default --no-daemonSummary by CodeRabbit