mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
fix(core): seeking a film with many videos no longer hangs Safari (#8278)
* ci(player): the Safari films check can run one film many times Started by hand, the workflow takes a film list, a run count and a browser list, and each such start runs beside the others instead of cancelling them. A fault that shows in one run of a film out of many needs hundreds of runs of that film to be seen, and to be shown gone. Pushes, pull requests and the nightly run are unchanged: every heavy film, twice, in Safari and Chrome. * fix(core): seeking a film with many videos no longer hangs Safari A seek in a player frame holds the picture each shown video is showing. Since #7971 that picture is drawn through a VideoFrame of the video, which spares Chromium's image decode cache. WebKit has no such cache, and in Safari making a VideoFrame of a video that was just paused can block the page's main thread without end: the first seek after playback of a film with sixteen 1080p videos never came back, and the "Heavy films: Safari vs Chrome" check failed on it with a driver timeout. WebKit now draws the held picture from the video element, as it did before #7971. Chromium keeps the VideoFrame route.
This commit is contained in:
@@ -14,10 +14,22 @@ on:
|
||||
- ".github/workflows/player-safari.yml"
|
||||
schedule:
|
||||
- cron: "23 7 * * *"
|
||||
# One film many times: a fault that shows once in fifty runs needs hundreds of runs to prove gone.
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
fixtures:
|
||||
description: "Films to run, comma-separated (empty runs every heavy film)"
|
||||
default: ""
|
||||
runs:
|
||||
description: "Runs of each film"
|
||||
default: "2"
|
||||
browsers:
|
||||
description: "Browsers, comma-separated"
|
||||
default: "safari,chrome"
|
||||
|
||||
concurrency:
|
||||
group: player-safari-${{ github.ref }}
|
||||
# Each dispatch is its own group: the runs of one proof go side by side instead of cancelling each other.
|
||||
group: player-safari-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && github.run_id || 'auto' }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
@@ -66,9 +78,14 @@ jobs:
|
||||
|
||||
- name: Run heavy films in Safari and Chrome
|
||||
working-directory: packages/player
|
||||
env:
|
||||
FIXTURES: ${{ inputs.fixtures }}
|
||||
RUNS: ${{ inputs.runs || '2' }}
|
||||
BROWSERS: ${{ inputs.browsers || 'safari,chrome' }}
|
||||
run: |
|
||||
sw_vers
|
||||
CHROMEDRIVER="$CHROMEWEBDRIVER/chromedriver" bun run tests/perf/browsers/run.ts --browsers safari,chrome --runs 2
|
||||
CHROMEDRIVER="$CHROMEWEBDRIVER/chromedriver" bun run tests/perf/browsers/run.ts \
|
||||
--browsers "$BROWSERS" --runs "$RUNS" ${FIXTURES:+--fixtures "$FIXTURES"}
|
||||
|
||||
- name: Upload results
|
||||
if: always()
|
||||
|
||||
@@ -269,6 +269,8 @@ it("does not retire an adopted decoded picture when its native snapshot lease en
|
||||
expect(video.currentTime).toBe(3);
|
||||
});
|
||||
|
||||
const MAC_SAFARI =
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/27.2 Safari/605.1.15";
|
||||
const MAC_CHROME =
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36";
|
||||
|
||||
@@ -331,6 +333,7 @@ it("draws a held picture through a VideoFrame closed after the draw, else from t
|
||||
const video = document.createElement("video");
|
||||
Object.defineProperty(video, "videoWidth", { value: 64 });
|
||||
Object.defineProperty(video, "videoHeight", { value: 36 });
|
||||
vi.stubGlobal("navigator", { userAgent: MAC_CHROME });
|
||||
vi.stubGlobal("VideoFrame", FakeVideoFrame);
|
||||
expect(captureNativeVideoFrame(video)?.width).toBe(64);
|
||||
const [first] = draws;
|
||||
@@ -350,3 +353,30 @@ it("draws a held picture through a VideoFrame closed after the draw, else from t
|
||||
expect(draws[1]?.source).toBe(video);
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
// fails without the fix: seeking a film of 16 1080p videos, Safari never came back from making a VideoFrame of a
|
||||
// video it had just paused. The frame route is for Chromium's image cache, which WebKit does not have.
|
||||
it("draws a held picture from the video itself in WebKit, making no VideoFrame", () => {
|
||||
const draws: unknown[] = [];
|
||||
let framesMade = 0;
|
||||
vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockReturnValue({
|
||||
drawImage: (source: unknown) => draws.push(source),
|
||||
} as unknown as CanvasRenderingContext2D);
|
||||
const video = document.createElement("video");
|
||||
Object.defineProperty(video, "videoWidth", { value: 64 });
|
||||
Object.defineProperty(video, "videoHeight", { value: 36 });
|
||||
vi.stubGlobal("navigator", { userAgent: MAC_SAFARI });
|
||||
vi.stubGlobal(
|
||||
"VideoFrame",
|
||||
class {
|
||||
constructor() {
|
||||
framesMade++;
|
||||
}
|
||||
close() {}
|
||||
},
|
||||
);
|
||||
expect(captureNativeVideoFrame(video)?.width).toBe(64);
|
||||
expect(framesMade).toBe(0);
|
||||
expect(draws).toEqual([video]);
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MEDIA_ELEMENT_LEAD_SECONDS } from "./mediaClock";
|
||||
import { isWebKit, MEDIA_ELEMENT_LEAD_SECONDS } from "./mediaClock";
|
||||
import { COLOR_GRADING_SOURCE_HIDDEN_ATTR } from "../colorGrading";
|
||||
import { applyNativeVideoLook } from "./nativeVideoLook";
|
||||
import {
|
||||
@@ -91,7 +91,10 @@ export function captureNativeVideoFrame(video: HTMLVideoElement): HTMLCanvasElem
|
||||
}
|
||||
}
|
||||
|
||||
const videoFrameOfAVideoCanHangThePage = isWebKit;
|
||||
|
||||
function videoFrameOf(video: HTMLVideoElement): VideoFrame | null {
|
||||
if (videoFrameOfAVideoCanHangThePage()) return null;
|
||||
try {
|
||||
return new VideoFrame(video);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user