Skip to content

Stop reloading the live view video on every interaction in Safari - #487

Open
masnwilliams wants to merge 1 commit into
mainfrom
hypeship/live-view-safari-stall-flash
Open

masnwilliams wants to merge 1 commit into
mainfrom
hypeship/live-view-safari-stall-flash

Conversation

@masnwilliams

@masnwilliams masnwilliams commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On iPhone the live view flashes black on most taps and key presses since #480.

#480 reloads the video from its stream when it is playing but has decoded no frame since a check at least a second earlier, and runs that check on every touchend and key press. Frames are counted with getVideoPlaybackQuality().totalVideoFrames, which Safari does not report for a MediaStream (it stays 0; WebKit bug 310007). So in Safari every interaction more than a second after the previous one counted as a stall and reset srcObject, which blanks the video until the next frame arrives.

Changes

  • VideoResume only detects stalls once the frame counter has reported a frame. A counter stuck at 0 says nothing about a stall, so Safari keeps the paused-video recovery from Keep the live view video playing on Android, and resume it when it stops #480 (play, muted fallback, "Tap to resume video") but no longer reloads a playing stream. Chrome, where the counter advances, behaves as before.

Testing

  • bun test tests: 249 pass. The new test (a counter that stays at 0 across checks a second apart is never reloaded) fails against the previous video-resume.ts.
  • Not run on a physical iPhone.

Note

Low Risk
Targeted change to live-view stall detection with a new unit test; Chrome path unchanged once frames are counted.

Overview
Fixes Safari live view flashing black on taps and key presses by tightening when stall reload runs.

VideoResume now treats a stuck-at-zero frame counter as “not counting” until totalVideoFrames (or equivalent progress) has been > 0 at least once. Only after that does unchanged progress for STALL_MS trigger reloading srcObject. Safari keeps #480 behavior for paused/blocked playback, but no longer reloads a playing MediaStream when the counter never advances. Chrome stall recovery is unchanged when frames increment.

Adds a test that a video whose frame count stays 0 is never reloaded across repeated stall-interval checks.

Reviewed by Cursor Bugbot for commit 7a58335. Bugbot is set up for automated code reviews on this repo. Configure here.

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