Skip to content

⚡ Bolt: fix macOS slider zero-tolerance seek overhead during drag - #2

Open
is52hertz wants to merge 1 commit into
mainfrom
bolt/macos-slider-scrub-13677156082657149377
Open

⚡ Bolt: fix macOS slider zero-tolerance seek overhead during drag#2
is52hertz wants to merge 1 commit into
mainfrom
bolt/macos-slider-scrub-13677156082657149377

Conversation

@is52hertz

Copy link
Copy Markdown
Owner

💡 What:
Replaced the viewModel.seek(to:) call with viewModel.scrub(to:) during continuous drag events in GlassSlider on macOS. Added an onEditingChanged callback to GlassSlider to surface interaction state up to PlayerView.

🎯 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 using scrub(to:) instead (which leverages positiveInfinity tolerance 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

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>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +35 to +36
if !isDragging {
onEditingChanged?(true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 在拖动取消时清除交互状态

当拖动过程中 PlayerView 被替换时(例如播放器报错使 ContentView 切换到错误界面),SwiftUI 会取消手势而不保证执行 .onEnded,因此这里发出的 true 没有对应的 false。macOS 的 PlayerViewModelAppDelegate 持久持有,后续重新加载视频时 isInteractingWithControls 仍为真,会一直屏蔽 onTimeUpdate 并阻止控件自动隐藏;请改用可在取消时自动复位的 @GestureState,或为取消/视图消失路径补充成对的 ViewModel 交互结束意图。

AGENTS.md reference: AGENTS.md:L158-L163

Useful? React with 👍 / 👎.

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