⚡ Bolt: fix macOS slider zero-tolerance seek overhead during drag - #2
⚡ Bolt: fix macOS slider zero-tolerance seek overhead during drag#2is52hertz wants to merge 1 commit into
Conversation
Replaces `viewModel.seek(to:)` with `viewModel.scrub(to:)` during continuous drag events in `GlassSlider` on macOS. In `AVPlayerEngine`, `seek(to:)` issues zero-tolerance seeks which forces precise frame decoding. At 60Hz UI refresh, dragging the slider previously flooded the decoder, causing severe backlog and main thread stalls. Added `onEditingChanged` callback to `GlassSlider` to properly demarcate the drag interaction, allowing `PlayerView` to manage `isInteractingWithControls` (suppressing auto-hide) and issue a final precise `seek(to:)` on release. Co-authored-by: is52hertz <144510573+is52hertz@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46ed2c6e59
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !isDragging { | ||
| onEditingChanged?(true) |
There was a problem hiding this comment.
当拖动过程中 PlayerView 被替换时(例如播放器报错使 ContentView 切换到错误界面),SwiftUI 会取消手势而不保证执行 .onEnded,因此这里发出的 true 没有对应的 false。macOS 的 PlayerViewModel 由 AppDelegate 持久持有,后续重新加载视频时 isInteractingWithControls 仍为真,会一直屏蔽 onTimeUpdate 并阻止控件自动隐藏;请改用可在取消时自动复位的 @GestureState,或为取消/视图消失路径补充成对的 ViewModel 交互结束意图。
AGENTS.md reference: AGENTS.md:L158-L163
Useful? React with 👍 / 👎.
💡 What:
Replaced the
viewModel.seek(to:)call withviewModel.scrub(to:)during continuous drag events inGlassSlideron macOS. Added anonEditingChangedcallback toGlassSliderto surface interaction state up toPlayerView.🎯 Why:
In
AVPlayerEngine,seek(to:)enforces zero-tolerance seeking to decode the exact frame requested. Calling this directly via a SwiftUI Binding setter inside a DragGesture meant issuing zero-tolerance seeks on every display frame (~60Hz). This creates massive decoder backlog and stalls the main thread. By usingscrub(to:)instead (which leveragespositiveInfinitytolerance to snap to I-frames quickly), scrub performance is drastically improved. A final zero-tolerance seek is issued when dragging ends.📊 Impact:
Eliminates main thread stuttering and severe decoding backlogs on macOS when dragging the slider. Allows smooth, low-latency live scrubbing equivalent to the iOS touch implementation.
🔬 Measurement:
Run the app on macOS. Load a video file. Try quickly dragging the progress slider back and forth. You should observe no stuttering or lag in the UI responsiveness.
PR created automatically by Jules for task 13677156082657149377 started by @is52hertz