-
Notifications
You must be signed in to change notification settings - Fork 0
Stabilize browser CI checks #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ | |
| const minimumAudibleFrequencyValue = 8; | ||
| const minimumVisibleChannelValue = 12; | ||
| const minimumVisiblePixelCount = 16; | ||
| const visibleVideoProbeTimeoutMs = 1500; | ||
| const visibleVideoPollDelayMs = 100; | ||
| const readyStateHaveCurrentData = 2; | ||
|
|
||
| if (typeof window[harnessGlobalName] === "object" && window[harnessGlobalName] !== null) { | ||
|
|
@@ -115,6 +117,36 @@ | |
| }; | ||
| } | ||
|
|
||
| async function waitForNextVideoFrame(videoElement) { | ||
| if (typeof videoElement.requestVideoFrameCallback === "function") { | ||
| await new Promise(resolve => videoElement.requestVideoFrameCallback(() => resolve())); | ||
| return; | ||
| } | ||
|
|
||
| await new Promise(resolve => window.setTimeout(resolve, visibleVideoPollDelayMs)); | ||
| } | ||
|
Comment on lines
+120
to
+127
|
||
|
|
||
| async function detectVisibleVideoAcrossFrames(videoElement) { | ||
| const deadline = Date.now() + visibleVideoProbeTimeoutMs; | ||
| let highestVisiblePixelCount = 0; | ||
|
|
||
| while (Date.now() <= deadline) { | ||
| const sample = detectVisibleVideo(videoElement); | ||
| highestVisiblePixelCount = Math.max(highestVisiblePixelCount, sample.nonBlackPixelCount); | ||
|
|
||
| if (sample.hasVisibleVideo) { | ||
| return sample; | ||
| } | ||
|
|
||
| await waitForNextVideoFrame(videoElement); | ||
| } | ||
|
|
||
| return { | ||
| hasVisibleVideo: highestVisiblePixelCount >= minimumVisiblePixelCount, | ||
| nonBlackPixelCount: highestVisiblePixelCount | ||
| }; | ||
| } | ||
|
|
||
| async function analyzeSavedRecording() { | ||
| if (!(savedBlob instanceof Blob)) { | ||
| return null; | ||
|
|
@@ -139,7 +171,7 @@ | |
| : null; | ||
| const hasAudioTrack = Boolean(captureStream?.getAudioTracks?.().length); | ||
| const hasAudibleAudio = await detectAudibleAudio(captureStream); | ||
| const visibleVideo = detectVisibleVideo(videoElement); | ||
| const visibleVideo = await detectVisibleVideoAcrossFrames(videoElement); | ||
|
|
||
| captureStream?.getTracks?.().forEach(track => track.stop()); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
animationFramePassesis checked before it is incremented, socaptureOnAnimationFramewill run one extrarequestAnimationFramecallback beyondmaxAnimationFramePasses(it still captures once more before returning). If the intent is to cap RAF sampling to exactlymaxAnimationFramePasses, increment before the check or adjust the comparison so the maximum number of scheduled passes matches the constant.