Skip to content

The free and privacy-friendly screen recorder with no limits πŸŽ₯

Recover macOS static-screen recordings that starved the encoder of a first frame

Alyssa X1e5d44c836aa
diff --git a/package.json b/package.json
index 0df247c..c37dd80 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "screenity",
- "version": "4.5.0",
+ "version": "4.5.1",
"description": "The free and privacy-friendly screen recorder with no sign in needed.",
"scripts": {
"build": "cross-env NODE_ENV=production node utils/build.js",
diff --git a/src/manifest.json b/src/manifest.json
index 842fef2..52a9af8 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -3,7 +3,7 @@
"name": "__MSG_extName__",
"description": "__MSG_extDesc__",
"default_locale": "en",
- "version": "4.5.0",
+ "version": "4.5.1",
"background": {
"service_worker": "background.bundle.js"
},
diff --git a/src/media/fastRecorderGate.ts b/src/media/fastRecorderGate.ts
index b6fa0f2..90b8bbc 100644
--- a/src/media/fastRecorderGate.ts
+++ b/src/media/fastRecorderGate.ts
@@ -155,6 +155,21 @@ export const isFastRecorderFailureTransient = (
) {
return true;
}
+ // No-first-chunk watchdog with zero encoded frames: the capture track
+ // never delivered a frame (macOS static-screen starvation, cancel, or HW
+ // contention), not an encoder defect β€” so don't sticky-disable the device.
+ // The genuine "28-byte ftyp" silent-encoder defect this guard exists for
+ // draws real frames first (framesEncoded > 0) and only then emits no chunk,
+ // so that case still falls through to the sticky-disable below. Discriminate
+ // on framesEncoded, not the reason code.
+ if (
+ reasonCode === "webcodecs-no-first-chunk" &&
+ detail &&
+ detail.firstChunkSeen === false &&
+ detail.framesEncoded === 0
+ ) {
+ return true;
+ }
return false;
};
@@ -169,7 +184,14 @@ export const markFastRecorderFailure = async (
? details.detail
: null;
if (isFastRecorderFailureTransient(reasonCode, errStr, detail)) {
+ // Clear any sticky disable a coarser path set earlier in this same
+ // attempt (e.g. the BG no-first-chunk alarm fires without detail and
+ // can't discriminate; the detailed recorder-side report arriving here
+ // is authoritative). Reaching a WebCodecs failure at all means the gate
+ // allowed WebCodecs this attempt, so an outstanding sticky flag is
+ // either from this race or already expired β€” safe to clear.
await chrome.storage.local.set({
+ [STORAGE_KEYS.stickyDisabled]: false,
[STORAGE_KEYS.lastFailureAt]: Date.now(),
fastRecorderTransientFailure: {
reasonCode,
diff --git a/src/pages/EditorApp/context/ContentState.jsx b/src/pages/EditorApp/context/ContentState.jsx
index 607971a..1347532 100644
--- a/src/pages/EditorApp/context/ContentState.jsx
+++ b/src/pages/EditorApp/context/ContentState.jsx
@@ -1412,7 +1412,10 @@ const ContentState = (props) => {
const errCode = message?.errorCode || "OPFS_LOAD_FAILED";
contentStateRef.current.openModal(
chrome.i18n.getMessage("opfsLoadErrorTitle"),
- message?.why || chrome.i18n.getMessage("opfsLoadErrorDescription"),
+ // Never surface the raw internal `why` (e.g. "WebCodecs produced
+ // no encoded video within 12000ms") β€” it's engineer-facing. The
+ // raw string still rides along in the diag bundle via diagForward.
+ chrome.i18n.getMessage("opfsLoadErrorDescription"),
null,
chrome.i18n.getMessage("permissionsModalDismiss"),
() => {},
@@ -1727,10 +1730,6 @@ const ContentState = (props) => {
typeof contentStateRef.current?.openModal === "function"
) {
editorErrorShownRef.current = true;
- // prefer i18n over raw codes like "REC_STOP_NO_CHUNKS"
- const rawWhy = payload?.why;
- const whyIsCode =
- typeof rawWhy === "string" && /^[A-Z][A-Z0-9_]+$/.test(rawWhy);
// pipeline failures get copy that says the recording may still be on-device
const pipelineFailureCodes = new Set([
"EDITOR_TAB_LOAD_TIMEOUT",
@@ -1754,10 +1753,8 @@ const ContentState = (props) => {
);
} else {
title = chrome.i18n.getMessage("opfsLoadErrorTitle");
- description =
- whyIsCode || !rawWhy
- ? chrome.i18n.getMessage("opfsLoadErrorDescription")
- : rawWhy;
+ // Never surface the raw internal `why` to users (see above).
+ description = chrome.i18n.getMessage("opfsLoadErrorDescription");
}
contentStateRef.current.openModal(
title,
@@ -1885,7 +1882,8 @@ const ContentState = (props) => {
const errCode = payload?.errorCode || "OPFS_LOAD_FAILED";
contentStateRef.current.openModal(
chrome.i18n.getMessage("opfsLoadErrorTitle"),
- payload?.why || chrome.i18n.getMessage("opfsLoadErrorDescription"),
+ // Never surface the raw internal `why` to users (see above).
+ chrome.i18n.getMessage("opfsLoadErrorDescription"),
null,
chrome.i18n.getMessage("permissionsModalDismiss"),
() => {},
diff --git a/src/pages/Recorder/Recorder.jsx b/src/pages/Recorder/Recorder.jsx
index b9a2cd0..ac936d8 100644
--- a/src/pages/Recorder/Recorder.jsx
+++ b/src/pages/Recorder/Recorder.jsx
@@ -2077,13 +2077,17 @@ const Recorder = () => {
// landed and the capture track is still live, swap to
// MediaRecorder via a recursive startRecording() so the user
// doesn't have to re-pick the screen / re-grant prompts.
+ // NOT gated on `transient`: a live track with zero chunks is the
+ // canonical recoverable case (e.g. a no-first-chunk stall on a
+ // static screen), and that's exactly when a silent swap should
+ // run. Transient failures whose track is already gone (cancel,
+ // track-ended, stream-missing) fail `trackLive` and skip it.
const liveVideoTrack =
liveStream.current?.getVideoTracks?.()[0] || null;
const trackLive = liveVideoTrack?.readyState === "live";
const noChunksYet =
savedCount.current === 0 && !hasChunks.current;
if (
- !transient &&
!webcodecsFallbackTriggered &&
noChunksYet &&
trackLive
@@ -3947,8 +3951,12 @@ const Recorder = () => {
!isTab.current &&
data.recordingType !== "region"
) {
- if (screenDisplayMediaMode) {
- debug("screen capture via getDisplayMedia (mac+141)");
+ if (IS_OFFSCREEN_HOST || screenDisplayMediaMode) {
+ // Offscreen docs can't consume a chrome.desktopCapture streamId
+ // (AbortError "Error starting tab capture", esp. on Windows), so the
+ // offscreen recorder always uses getDisplayMedia for screen capture,
+ // matching CloudRecorder. mac+141 also uses it for system audio.
+ debug("screen capture via getDisplayMedia (offscreen or mac+141)");
slLog("getDisplayMedia-screen-route");
chrome.storage.local.set({ lastScreenCaptureApi: "getDisplayMedia" });
startStream(data, null, null, permissions, permissions2, {
diff --git a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
index 2eae2e5..733ae9b 100644
--- a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
+++ b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
@@ -272,6 +272,9 @@ export class WebCodecsRecorder {
this._chunksOut = 0;
this._framesFromMSTP = 0;
this._staticFrameSyntheticCount = 0;
+ // Black placeholder frames synthesized before the first real frame to
+ // bridge macOS static-screen first-frame starvation (see readVideoLoop).
+ this._syntheticFirstFrameCount = 0;
this._firstChunkAt = null;
this._encoderConstructCount = 0;
this._videoEncoderStateAtStop = null;
@@ -1125,6 +1128,11 @@ export class WebCodecsRecorder {
err.detail = {
framesEncoded: this.frameCount,
firstChunkSeen: this._firstChunkSeen,
+ // Real frames read off the track vs black placeholders synthesized to
+ // bridge static-screen first-frame starvation. framesFromMSTP === 0
+ // pins capture-track starvation (transient) over an encoder defect.
+ framesFromMSTP: this._framesFromMSTP,
+ syntheticFirstFrameCount: this._syntheticFirstFrameCount,
droppedForBackpressure: {
video: this._droppedForBackpressureCount,
audio: this._droppedAudioForBackpressureCount,
@@ -2338,13 +2346,37 @@ export class WebCodecsRecorder {
let isSynthetic = false;
let frame = null;
if (readResult.isSyntheticTimeout) {
- // Track stalled; only synthesize if we've drawn a frame
- // already (else first-chunk watchdog handles no-frames).
- if (!this._firstChunkSeen || !this.resizeCanvas) {
- continue;
+ if (!this._firstChunkSeen) {
+ // No real frame has arrived yet. macOS ScreenCaptureKit can
+ // withhold the very first frame on a fully static screen, which
+ // starves the encoder and trips the no-first-chunk watchdog even
+ // though capture is healthy. While the track is live, prime the
+ // stream with a black placeholder so the encoder starts and the
+ // watchdog disarms; the first real frame replaces it the moment
+ // the screen changes. If the track is gone (ended / muted / not
+ // ready) leave it to the watchdog to surface the real failure.
+ const trackLive =
+ this.videoTrack &&
+ this.videoTrack.readyState === "live" &&
+ this.videoTrack.muted !== true;
+ if (!trackLive || !this.targetWidth || !this.targetHeight) {
+ continue;
+ }
+ ensureResizeCanvas();
+ if (this._videoStartUs == null) {
+ this._videoStartUs = performance.now() * 1000;
+ }
+ isSynthetic = true;
+ this._syntheticFirstFrameCount += 1;
+ } else {
+ // Track stalled mid-stream; reuse the last drawn frame so chunks
+ // keep flowing through the static stretch.
+ if (!this.resizeCanvas) {
+ continue;
+ }
+ isSynthetic = true;
+ this._staticFrameSyntheticCount += 1;
}
- isSynthetic = true;
- this._staticFrameSyntheticCount += 1;
} else {
if (readResult.done || !readResult.value) break;
frame = readResult.value;