Repository navigation
Stop reloading the live view video on every interaction in iOS browsers - #487
Open
masnwilliams wants to merge 1 commit into
Open
masnwilliams wants to merge 1 commit into
masnwilliams wants to merge 1 commit into
Conversation
masnwilliams
force-pushed
the
hypeship/live-view-safari-stall-flash
branch
from
October 26, 2026 18:49
7a58335 to
fa7a153
Compare
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit fa7a153. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On iPhone the live view flashes black on most taps and key presses since #480, in Safari and in Chrome. Every iOS browser runs on WebKit, so they share the behavior below.
#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 WebKit on iOS does not report for aMediaStream(it stays 0; WebKit bug 310007). So in iOS browsers every interaction more than a second after the previous one counted as a stall and resetsrcObject, which blanks the video until the next frame arrives.Changes
VideoResumeonly detects stalls once the frame counter has reported a frame. A counter stuck at 0 says nothing about a stall, so iOS browsers keep 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 reload a playing stream. Browsers whose counter advances behave as before; Chromium on Linux, with and without iPhone emulation, counted MediaStream frames in testing.Testing
bun test tests: 251 pass. The new test (a counter that stays at 0 across checks a second apart is never reloaded) fails against the previousvideo-resume.ts.getVideoPlaybackQuality()was stubbed to report 0 frames as iOS WebKit does. Four taps 1.3s apart:srcObject(emptied,readyState0), leaving the video with no picture for 124–145ms; screenshots right after those taps are black;Note
Low Risk
Targeted change to client-side stall heuristics for live video; Chrome stall recovery is preserved and Safari avoids erroneous reloads.
Overview
Fixes live view flashing black on most taps/key presses in Safari by tightening when stall recovery reloads the stream.
VideoResumeusedgetVideoPlaybackQuality().totalVideoFramesto detect a playing video that stopped decoding; Safari keeps that at 0 forMediaStream, so every interaction after ~1s was treated as a stall andsrcObjectwas reset. The change adds acountinggate: stall reload only runs after the frame counter has reported at least one frame (progress > 0). Browsers that never advance the counter skip reload but still get paused/blocked playback handling from #480; Chrome behavior is unchanged.Adds a unit test that a video with frames stuck at 0 is never reloaded across repeated stall-interval checks.
Reviewed by Cursor Bugbot for commit fa7a153. Bugbot is set up for automated code reviews on this repo. Configure here.