Skip to content

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

Encoder-failure fallback, watchdog false positives, and false load errors

Alyssa X4aa911a0b673
diff --git a/package.json b/package.json
index b2c2d56..e5afe4d 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "screenity",
- "version": "4.6.0",
+ "version": "4.6.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 15ba485..b31b260 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -3,7 +3,7 @@
"name": "__MSG_extName__",
"description": "__MSG_extDesc__",
"default_locale": "en",
- "version": "4.6.0",
+ "version": "4.6.1",
"background": {
"service_worker": "background.bundle.js"
},
diff --git a/src/media/fastRecorderGate.ts b/src/media/fastRecorderGate.ts
index 08dc9f7..7f2d9c7 100644
--- a/src/media/fastRecorderGate.ts
+++ b/src/media/fastRecorderGate.ts
@@ -217,6 +217,9 @@ export const markFastRecorderFailure = async (
[STORAGE_KEYS.stickyDetails]: details,
[STORAGE_KEYS.lastFailureAt]: Date.now(),
});
+ // A real failure outranks a cached probe pass, which would otherwise
+ // vouch for this machine for the rest of its TTL.
+ await invalidateCachedProbe();
} catch {
// ignore
}
@@ -385,6 +388,16 @@ let _probeInMemory: FastRecorderProbeResult | null = null;
let _probeInMemoryAt = 0;
let _probeInFlight: Promise<FastRecorderProbeResult> | null = null;
+const invalidateCachedProbe = async () => {
+ _probeInMemory = null;
+ _probeInMemoryAt = 0;
+ try {
+ await chrome.storage.local.remove(STORAGE_KEYS.probe);
+ } catch {
+ // ignore
+ }
+};
+
const tryReadCachedProbe = async (): Promise<FastRecorderProbeResult | null> => {
if (_probeInMemory) {
if (_probeInMemory.ok) return _probeInMemory;
@@ -794,6 +807,12 @@ const _probeFastRecorderSupportUncached = async (): Promise<FastRecorderProbeRes
}
};
+// Unset must stay null: shouldUseFastRecorder lets an explicit `true` override
+// a sticky disable, so folding unset into true makes the disable unreachable.
+export const resolveFastRecorderUserSetting = (
+ raw: unknown
+): boolean | null => (raw === true ? true : raw === false ? false : null);
+
export const shouldUseFastRecorder = (
userSetting: boolean | null | undefined,
probeResult: FastRecorderProbeResult,
diff --git a/src/pages/Background/alarms/handleAlarm.js b/src/pages/Background/alarms/handleAlarm.js
index ef1b781..8de0ee4 100644
--- a/src/pages/Background/alarms/handleAlarm.js
+++ b/src/pages/Background/alarms/handleAlarm.js
@@ -20,6 +20,12 @@ import {
export { FIRST_CHUNK_WATCHDOG_ALARM, RECORDER_KEEPALIVE_ALARM };
+// First alarm stays short to catch a dead capture fast; once there's evidence
+// of life it backs off to this. Bounded so a capture producing nothing still
+// ends in an error rather than an endless zero-byte recording.
+const FIRST_CHUNK_WATCHDOG_REARM_MS = 20_000;
+const FIRST_CHUNK_WATCHDOG_MAX_REARMS = 3;
+
// WebCodecs muxer only finalizes inside the recorder tab; without this salvage
// step the MP4 moov never gets written and chunks on disk are unplayable.
const STALL_RECOVERY_TIMEOUT_MS = 5000;
@@ -229,7 +235,11 @@ export const handleAlarm = async (alarm) => {
}
if (alarm.name === FIRST_CHUNK_WATCHDOG_ALARM) {
- const { recording } = await chrome.storage.local.get(["recording"]);
+ const { recording, firstChunkWatchdogState: watchdogState } =
+ await chrome.storage.local.get([
+ "recording",
+ "firstChunkWatchdogState",
+ ]);
if (recording) {
diagEvent("error", { note: "first-chunk-watchdog-fired" });
// Snapshot the recorder first (1500ms cap so a wedged tab can't delay the
@@ -262,6 +272,77 @@ export const handleAlarm = async (alarm) => {
} catch {}
const vt = snapshot?.stream?.videoTrack || null;
+ // Fail on missing frames, not a missing chunk. First-chunk latency is
+ // unbounded (cold start, keyframe cadence, slow disk); frame arrival
+ // isn't, so zero frames means capture is dead at 8s or at 80s. Slow
+ // encoding is the recorder's problem, and it has its own stall watchdog.
+ const progress = snapshot?.progress || null;
+ const counts = snapshot?.counts || null;
+ const flags = snapshot?.flags || null;
+ const bytesExist =
+ Boolean(counts) &&
+ (Number(counts.saved) > 0 ||
+ Number(counts.pendingBytes) > 0 ||
+ counts.hasChunks === true);
+ const framesArriving =
+ Boolean(progress) &&
+ (Number(progress.frameCount) > 0 ||
+ Number(progress.framesFromMSTP) > 0);
+ const rearmCount = Number(watchdogState?.rearms) || 0;
+ const canRearm = rearmCount < FIRST_CHUNK_WATCHDOG_MAX_REARMS;
+
+ const rearm = async (reason) => {
+ diagEvent("warning", {
+ note: "first-chunk-watchdog-rearm",
+ reason,
+ rearms: rearmCount + 1,
+ });
+ await chrome.storage.local.set({
+ firstChunkWatchdogState: { rearms: rearmCount + 1, at: Date.now() },
+ });
+ await chrome.alarms.create(FIRST_CHUNK_WATCHDOG_ALARM, {
+ delayInMinutes: FIRST_CHUNK_WATCHDOG_REARM_MS / 60000,
+ });
+ };
+
+ if (bytesExist) {
+ // Data is on disk; the cancel message is fire-and-forget and was lost.
+ diagEvent("warning", { note: "first-chunk-watchdog-bytes-exist" });
+ await chrome.alarms.clear(FIRST_CHUNK_WATCHDOG_ALARM);
+ return;
+ }
+ if (flags?.paused === true) {
+ // A long pause must never age into a failure, so this ignores the cap.
+ await rearm("paused");
+ return;
+ }
+ if (!snapshot && canRearm) {
+ // A recorder too busy to answer in 1500ms isn't a dead capture; this
+ // used to hard-fail.
+ await rearm("no-snapshot");
+ return;
+ }
+ if (flags?.isStarting === true && canRearm) {
+ await rearm("still-starting");
+ return;
+ }
+ if (framesArriving && canRearm) {
+ // Encoder is being fed and just hasn't emitted yet: a cold start.
+ await rearm("frames-arriving-no-chunk-yet");
+ return;
+ }
+ // MediaRecorder has no frame counter; a live track plus state
+ // "recording" is the best evidence of life it can offer.
+ if (
+ !progress &&
+ snapshot?.recorder?.state === "recording" &&
+ vt?.readyState === "live" &&
+ vt?.muted === false &&
+ canRearm
+ ) {
+ await rearm("mediarecorder-running-no-chunk-yet");
+ return;
+ }
if (vt && vt.readyState === "live" && vt.muted === true) {
// Capture track is live but muted: the recorded tab is backgrounded,
// focus was lost, or the display slept, so no frames are arriving. That
@@ -282,7 +363,7 @@ export const handleAlarm = async (alarm) => {
Boolean(vt) && vt.readyState === "live" && vt.muted === false;
if (fastRecorderInUse && realEncoderDefect) {
await markFastRecorderFailure("webcodecs-no-first-chunk", {
- error: "WebCodecs produced no first chunk within 8s (watchdog)",
+ error: "WebCodecs capture produced no frames (watchdog)",
});
}
} catch (err) {
@@ -292,7 +373,7 @@ export const handleAlarm = async (alarm) => {
try {
await handleRecordingError({
error: "stream-error",
- why: "Recording failed: no video data received within 8 seconds. The tab may have been throttled. Please try again.",
+ why: "Recording failed: the capture produced no video frames. The tab may have been throttled. Please try again.",
errorCode: "no-first-chunk",
});
} catch (err) {
diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js
index f0590f6..f17291f 100644
--- a/src/pages/Background/index.js
+++ b/src/pages/Background/index.js
@@ -416,62 +416,3 @@ try {
});
} catch {}
-// ---- TEMP DEBUG: MediaRecorder-MP4 verification helpers (remove before commit) ----
-// SW console usage: mp4force() β†’ record + edit β†’ mp4test(). mp4reset() restores.
-try {
- globalThis.mp4force = async () => {
- await chrome.storage.local.set({ useWebCodecsRecorder: false });
- console.log("[mp4] fast recorder OFF, MediaRecorder path forced. Record now.");
- };
- globalThis.mp4reset = async () => {
- await chrome.storage.local.set({ useWebCodecsRecorder: true });
- console.log("[mp4] fast recorder ON, back to WebCodecs default.");
- };
- globalThis.mp4test = async () => {
- const s = await chrome.storage.local.get([
- "diagnosticLog", "editorReadyPath", "lastRecordingError",
- "useWebCodecsRecorder", "lastRecordingBackendRef", "__mp4dbg", "__hiResResult",
- ]);
- const ses = s.diagnosticLog?.sessions?.slice(-1)[0];
- const evs = ses?.events || [];
- const lastEv = (e) => [...evs].reverse().find((x) => x.e === e);
- const has = (e) => evs.some((x) => x.e === e);
- const ok = (b) => (b ? "βœ…" : "❌");
-
- // backend is the ground truth (single storage key, never rotates):
- // opfs = WebCodecs, idb = MediaRecorder. recorder-finalize-summary is a
- // WebCodecs-only session marker that corroborates it.
- const backend = s.lastRecordingBackendRef?.backend || null;
- const ranMR = backend === "idb" && !has("recorder-finalize-summary");
- const recorder = ranMR ? "MediaRecorder" : backend === "opfs" || has("recorder-finalize-summary") ? "WebCodecs" : "unknown";
-
- // Durable mime written by createMediaRecorder (survives lifecycle-log rotation).
- const mime = s.__mp4dbg?.mime || null;
- const container = s.__mp4dbg?.container || null;
- const mp4Container = container === "mp4";
- const path = lastEv("editor-load-ready")?.d?.path || s.editorReadyPath || null;
- const mp4Route = path === "mp4-fast";
- const meta = lastEv("sandbox-video-loadedmetadata")?.d || {};
- const durOk = Number.isFinite(meta.duration) && meta.duration > 0;
- const errs = evs.filter((x) => /error/i.test(x.e)).map((x) => x.e);
- const pass = ranMR && mp4Container && mp4Route && durOk && !errs.length;
-
- console.log("%c── Screenity MR-MP4 test ── " + (pass ? "PASS βœ…" : ranMR ? "CHECK ❌" : "WRONG RECORDER ⚠️"), "font-weight:bold");
- console.log("recorder that ran:", recorder, "(backend:", backend + ")", ok(ranMR),
- ranMR ? "" : "β†’ not the MediaRecorder path; turn OFF \"Fast MP4\" then record a NEW clip");
- console.log("(a) container:", container, ok(mp4Container), " [mime:", mime, "]", mp4Container ? "β†’ stayed MP4" : "β†’ fell back to WebM");
- console.log("(b) editor route:", path, ok(mp4Route), mp4Route ? "β†’ MP4 fast path" : "β†’ WebM/remux path");
- console.log(" duration:", meta.duration, ok(durOk), " dims:", meta.width + "x" + meta.height);
- console.log(" editor errors:", errs.length ? errs : "none", ok(!errs.length));
- console.log(" lastRecordingError:", s.lastRecordingError || "none");
- console.log(" Fast-MP4-off flag:", s.useWebCodecsRecorder, " session:", ses?.id, ses?.config?.recordingType, "β†’", ses?.outcome);
- const hr = s.__hiResResult;
- if (hr) {
- console.log("%c capture track:", "color:#888",
- hr.width + "x" + hr.height, hr.displaySurface || "",
- "| requested", hr.requested, "| hiResTest:", hr.hiResTest);
- }
- return pass;
- };
-} catch {}
-// ---- END TEMP DEBUG ----
diff --git a/src/pages/Background/recording/startRecording.js b/src/pages/Background/recording/startRecording.js
index bf98975..7a47729 100644
--- a/src/pages/Background/recording/startRecording.js
+++ b/src/pages/Background/recording/startRecording.js
@@ -232,6 +232,8 @@ const _startRecordingInner = async (caller) => {
editorRecordingError: null,
editorReadyAt: null,
editorReadyPath: null,
+ // re-arm count is per-attempt; a leaked one would fail this recording early
+ firstChunkWatchdogState: null,
// prior sandboxTab would route this attempt's errors to the wrong editor
sandboxTab: null,
// paused leak from a prior errored recording would mis-account duration
diff --git a/src/pages/Content/popup/layout/SettingsMenu.jsx b/src/pages/Content/popup/layout/SettingsMenu.jsx
index 5fb91be..a513162 100644
--- a/src/pages/Content/popup/layout/SettingsMenu.jsx
+++ b/src/pages/Content/popup/layout/SettingsMenu.jsx
@@ -16,6 +16,7 @@ import { contentStateContext } from "../../context/ContentState";
import {
probeFastRecorderSupport,
shouldUseFastRecorder,
+ resolveFastRecorderUserSetting,
getFastRecorderStickyState,
} from "../../../../media/fastRecorderGate";
import { resetOnboardingSeen } from "../onboarding/storage";
@@ -134,12 +135,9 @@ const SettingsMenu = (props) => {
const runFastRecorderProbe = async (source = "auto") => {
if (!contentState) return;
- const userSetting =
- contentState.useWebCodecsRecorder === true
- ? true
- : contentState.useWebCodecsRecorder === false
- ? false
- : null;
+ const userSetting = resolveFastRecorderUserSetting(
+ contentState.useWebCodecsRecorder,
+ );
const sticky = await getFastRecorderStickyState();
const probe = await probeFastRecorderSupport();
const useFast = shouldUseFastRecorder(userSetting, probe, sticky);
diff --git a/src/pages/EditorApp/context/ContentState.jsx b/src/pages/EditorApp/context/ContentState.jsx
index fbf9883..aa29c1a 100644
--- a/src/pages/EditorApp/context/ContentState.jsx
+++ b/src/pages/EditorApp/context/ContentState.jsx
@@ -57,6 +57,25 @@ localforage.config({
version: 1,
});
+// Codes meaning "ended early or never started", not "unreadable". The bytes
+// are usually fine, and if they aren't the OPFS/IDB read path raises the modal
+// itself with the real cause.
+const NON_LOAD_FAILURE_CODES = new Set([
+ // user dismissed Chrome's picker
+ "REC_START_CANCEL",
+ // watchdog stopped the take; whatever was captured is still on disk
+ "no-first-chunk",
+]);
+
+// These call sites hardcoded opfs-load-failed, so a picker-cancel was reported
+// as a storage fault.
+const supportSourceForCode = (code) =>
+ code === "OPFS_LOAD_FAILED" ? "opfs-load-failed" : "editor-recording-error";
+
+// Long enough for a normal OPFS open + read to land before we believe a stored
+// error.
+const DEFERRED_ERROR_MODAL_MS = 4000;
+
const chunksStore = localforage.createInstance({
name: "chunks",
storeName: "keyvaluepairs",
@@ -1567,12 +1586,19 @@ const ContentState = (props) => {
why: String(message?.why || "").slice(0, 240),
errorCode: message?.errorCode || null,
});
+ if (NON_LOAD_FAILURE_CODES.has(message?.errorCode)) {
+ diagForward("sandbox-recording-error-not-load-failure", {
+ errorCode: message?.errorCode || null,
+ source: "runtime",
+ });
+ return;
+ }
if (
!editorErrorShownRef.current &&
typeof contentStateRef.current?.openModal === "function"
) {
editorErrorShownRef.current = true;
- const errCode = message?.errorCode || "OPFS_LOAD_FAILED";
+ const errCode = message?.errorCode || "UNKNOWN";
contentStateRef.current.openModal(
chrome.i18n.getMessage("opfsLoadErrorTitle"),
// Never surface the raw internal `why` (e.g. "WebCodecs produced
@@ -1589,10 +1615,11 @@ const ContentState = (props) => {
true,
chrome.i18n.getMessage("getHelpButton"),
() => {
- triggerSupportDownload({ source: "opfs-load-failed" });
+ const src = supportSourceForCode(errCode);
+ triggerSupportDownload({ source: src });
chrome.runtime.sendMessage({
type: "report-error",
- source: "opfs-load-failed",
+ source: src,
errorCode: errCode,
zipBundled: true,
});
@@ -1894,6 +1921,13 @@ const ContentState = (props) => {
why: String(payload?.why || "").slice(0, 240),
errorCode: payload?.errorCode || null,
});
+ if (NON_LOAD_FAILURE_CODES.has(payload?.errorCode)) {
+ diagForward("sandbox-recording-error-not-load-failure", {
+ errorCode: payload?.errorCode || null,
+ source: "storage",
+ });
+ return;
+ }
if (
!editorErrorShownRef.current &&
typeof contentStateRef.current?.openModal === "function"
@@ -2022,6 +2056,42 @@ const ContentState = (props) => {
};
}, []);
+ const showParentRecordingErrorModal = (payload) => {
+ if (editorErrorShownRef.current) return;
+ if (typeof contentStateRef.current?.openModal !== "function") return;
+ editorErrorShownRef.current = true;
+ const errCode = payload?.errorCode || "UNKNOWN";
+ contentStateRef.current.openModal(
+ chrome.i18n.getMessage("opfsLoadErrorTitle"),
+ // Never surface the raw internal `why` to users (see above).
+ chrome.i18n.getMessage("opfsLoadErrorDescription"),
+ null,
+ chrome.i18n.getMessage("permissionsModalDismiss"),
+ () => {},
+ () => {},
+ null,
+ null,
+ null,
+ true,
+ chrome.i18n.getMessage("getHelpButton"),
+ () => {
+ const src = supportSourceForCode(errCode);
+ triggerSupportDownload({ source: src });
+ chrome.runtime.sendMessage({
+ type: "report-error",
+ source: src,
+ errorCode: errCode,
+ zipBundled: true,
+ });
+ },
+ );
+ setContentState((prev) => ({
+ ...prev,
+ ready: true,
+ recordingFailed: true,
+ }));
+ };
+
const onMessage = async (event) => {
// legacy window-message path; editor-force-close now arrives via
// chrome.runtime.onMessage. harmless no-op clearing beforeunload.
@@ -2038,46 +2108,43 @@ const ContentState = (props) => {
Boolean(contentStateRef.current?.ready) ||
Boolean(contentStateRef.current?.blob);
if (editorAlreadyLoaded) return;
+ // The storage listener filters by sandboxTab; this path never did, so it
+ // replayed errors stamped for a different editor tab.
+ const bridgeTabId = tabIdRef.current;
+ if (
+ bridgeTabId != null &&
+ payload?.sandboxTab != null &&
+ payload.sandboxTab !== bridgeTabId
+ ) {
+ return;
+ }
diagForward("sandbox-recording-error-received-via-parent", {
error: String(payload?.error || "").slice(0, 120),
why: String(payload?.why || "").slice(0, 240),
errorCode: payload?.errorCode || null,
});
- if (
- !editorErrorShownRef.current &&
- typeof contentStateRef.current?.openModal === "function"
- ) {
- editorErrorShownRef.current = true;
- const errCode = payload?.errorCode || "OPFS_LOAD_FAILED";
- contentStateRef.current.openModal(
- chrome.i18n.getMessage("opfsLoadErrorTitle"),
- // Never surface the raw internal `why` to users (see above).
- chrome.i18n.getMessage("opfsLoadErrorDescription"),
- null,
- chrome.i18n.getMessage("permissionsModalDismiss"),
- () => {},
- () => {},
- null,
- null,
- null,
- true,
- chrome.i18n.getMessage("getHelpButton"),
- () => {
- triggerSupportDownload({ source: "opfs-load-failed" });
- chrome.runtime.sendMessage({
- type: "report-error",
- source: "opfs-load-failed",
- errorCode: errCode,
- zipBundled: true,
- });
- },
- );
- setContentState((prev) => ({
- ...prev,
- ready: true,
- recordingFailed: true,
- }));
+ if (NON_LOAD_FAILURE_CODES.has(payload?.errorCode)) {
+ diagForward("sandbox-recording-error-not-load-failure", {
+ errorCode: payload?.errorCode || null,
+ source: "parent",
+ });
+ return;
}
+ // ready/blob are always false at mount (the blob needs a BG round-trip
+ // plus an OPFS read), so deciding here always showed the modal, including
+ // over recordings that load fine a moment later. Re-check instead.
+ setTimeout(() => {
+ const loaded =
+ Boolean(contentStateRef.current?.ready) ||
+ Boolean(contentStateRef.current?.blob);
+ if (loaded) {
+ diagForward("sandbox-recording-error-superseded-by-load", {
+ errorCode: payload?.errorCode || null,
+ });
+ return;
+ }
+ showParentRecordingErrorModal(payload);
+ }, DEFERRED_ERROR_MODAL_MS);
return;
}
if (event.data.type === "updated-blob") {
diff --git a/src/pages/Recorder/Recorder.jsx b/src/pages/Recorder/Recorder.jsx
index a539a4d..bcf1879 100644
--- a/src/pages/Recorder/Recorder.jsx
+++ b/src/pages/Recorder/Recorder.jsx
@@ -49,6 +49,7 @@ import {
import {
probeFastRecorderSupport,
shouldUseFastRecorder,
+ resolveFastRecorderUserSetting,
getFastRecorderStickyState,
markFastRecorderFailure,
validateFastRecorderOutputBlob,
@@ -1266,7 +1267,7 @@ const Recorder = () => {
}
}
- async function startRecording() {
+ async function startRecording({ forceMediaRecorder = false } = {}) {
if (process.env.SCREENITY_DEV_MODE === "true") {
console.log("[recorder-opfs][recorder] startRecording entry");
}
@@ -1429,13 +1430,15 @@ const Recorder = () => {
getFastRecorderStickyState(),
probeFastRecorderSupport(),
]);
- // Default-on: undefined means enabled; only explicit `false` opts out.
- const userSetting = userSettingRaw.useWebCodecsRecorder === false ? false : true;
- const shouldUseFast = shouldUseFastRecorder(
- userSetting,
- probeResult,
- stickyState,
+ const userSetting = resolveFastRecorderUserSetting(
+ userSettingRaw.useWebCodecsRecorder,
);
+ // A fallback re-entry must not re-pick WebCodecs: the sticky write races
+ // this read.
+ const shouldUseFast =
+ forceMediaRecorder
+ ? false
+ : shouldUseFastRecorder(userSetting, probeResult, stickyState);
// Extension must match the recorder that runs, not the probe. Fast path
// uses the probe container; MediaRecorder resolves its own from its mime.
const mediaRecorderContainer = containerForMime(selectRecorderMime(liveStream.current));
@@ -2304,7 +2307,7 @@ const Recorder = () => {
// recorder.current null and isStarting.current false).
isStarting.current = false;
try {
- await startRecording();
+ await startRecording({ forceMediaRecorder: true });
} catch (e) {
debugError("In-session swap startRecording threw", e);
chrome.runtime.sendMessage({
@@ -2372,9 +2375,9 @@ const Recorder = () => {
});
recorder.current = null;
// Abort the OPFS writer opened for the WebCodecs path. The recursive
- // startRecording() will pick IDB (userSetting=false now), but it
- // also nulls chunkWriter.current without closing; leaving the OPFS
- // file handle dangling.
+ // startRecording() picks IDB because forceMediaRecorder short-circuits
+ // the gate, but it also nulls chunkWriter.current without closing;
+ // leaving the OPFS file handle dangling.
if (chunkWriter.current) {
try {
await chunkWriter.current.abort();
@@ -2385,7 +2388,7 @@ const Recorder = () => {
// Top-of-startRecording guard requires both recorder null AND
// isStarting false; without this reset the recursive call bails.
isStarting.current = false;
- return await startRecording();
+ return await startRecording({ forceMediaRecorder: true });
}
await chrome.storage.local.set({ fastRecorderInUse: true });
@@ -2613,6 +2616,14 @@ const Recorder = () => {
recorderState: recorder.current?.state || null,
savedCount: savedCount.current,
});
+ // An empty blob still proves MediaRecorder is firing on schedule,
+ // and this branch returns before handleChunk, the only other
+ // canceller.
+ if (!hasChunks.current) {
+ chrome.runtime
+ .sendMessage({ type: "cancel-first-chunk-watchdog" })
+ .catch(() => {});
+ }
if (
recorder.current instanceof MediaRecorder &&
recorder.current.state === "inactive"
@@ -4603,6 +4614,12 @@ const Recorder = () => {
pendingBytes: pendingBytes.current ?? 0,
hasChunks: Boolean(hasChunks.current),
},
+ // Lets the watchdog tell a cold-starting encoder from one receiving
+ // nothing. Null on the MediaRecorder path.
+ progress:
+ r && useWebCodecs.current && typeof r.getProgressStats === "function"
+ ? r.getProgressStats()
+ : null,
stream: {
hasLive: Boolean(liveStream.current),
hasHelper: Boolean(helperVideoStream.current),
diff --git a/src/pages/Recorder/mediaRecorderUtils.js b/src/pages/Recorder/mediaRecorderUtils.js
index e414bab..a90a9a5 100644
--- a/src/pages/Recorder/mediaRecorderUtils.js
+++ b/src/pages/Recorder/mediaRecorderUtils.js
@@ -41,12 +41,5 @@ export function createMediaRecorder(
// browser can normalize the string.
recorder.__screenityContainer = containerForMime(mimeType);
recorder.__screenityMime = mimeType;
- // TEMP DEBUG (remove before commit): durable copy of the chosen mime so
- // mp4test() can read it even after the 500-entry lifecycle log rotates.
- try {
- chrome?.storage?.local?.set({
- __mp4dbg: { mime: mimeType, container: containerForMime(mimeType), at: Date.now() },
- });
- } catch {}
return recorder;
}
diff --git a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
index c8907b1..fc9fb34 100644
--- a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
+++ b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
@@ -129,6 +129,10 @@ export class WebCodecsRecorder {
this._videoLoopError = null;
this._firstChunkSeen = false;
this._firstChunkWatchdog = null;
+ this._hiddenRearmCount = 0;
+ // Matches FIRST_CHUNK_WATCHDOG_MAX_REARMS in the background watchdog;
+ // ~48s of hidden, output-free recording at the 12s default.
+ this._maxHiddenRearms = 3;
// 12s covers NVENC / VideoToolbox cold-start (5-7s on first encode).
// Shorter values false-fired into the MediaRecorder fallback.
this._firstChunkWatchdogMs = Number.isFinite(options.firstChunkWatchdogMs)
@@ -360,6 +364,7 @@ export class WebCodecsRecorder {
// reused instance can salvage again on a second recording.
this._didSwRetry = false;
this._swRetryReason = null;
+ this._hiddenRearmCount = 0;
this._lastChunkAt = null;
this._lastFailureCode = null;
this._forceNextKeyframe = false;
@@ -688,6 +693,26 @@ export class WebCodecsRecorder {
return this._startPromise;
}
+ // Lets the background watchdog tell "fed but not emitting yet" (cold start,
+ // 5-7s on NVENC / VideoToolbox) from "no frames arriving at all".
+ getProgressStats() {
+ let muxerEmits = null;
+ let muxerBytes = null;
+ try {
+ const s = this.muxer?.getStats?.();
+ muxerEmits = s?.emitCount ?? null;
+ muxerBytes = s?.totalEmittedBytes ?? null;
+ } catch {}
+ return {
+ frameCount: this.frameCount,
+ framesFromMSTP: this._framesFromMSTP,
+ chunksOut: this._chunksOut,
+ firstChunkSeen: this._firstChunkSeen,
+ muxerEmits,
+ muxerBytes,
+ };
+ }
+
async stop() {
this.log("[WCR] stop()", this.frameCount);
perfMark("WCR.stop.enter", { frameCount: this.frameCount });
@@ -1281,6 +1306,8 @@ export class WebCodecsRecorder {
!this._stopping &&
!this._firstChunkSeen
) {
+ // back in the foreground, so throttling no longer explains the silence
+ this._hiddenRearmCount = 0;
this._armFirstChunkWatchdog();
}
};
@@ -1357,11 +1384,20 @@ export class WebCodecsRecorder {
this._firstChunkWatchdog = null;
if (!this.running || this._stopping || this._firstChunkSeen) return;
// tab is hidden so the encoder may be throttled; re-arm and let the
- // visibilitychange handler restart the clock on return.
+ // visibilitychange handler restart the clock on return. Bounded: the
+ // region recorder is an injected iframe that stays hidden for the whole
+ // recording, so an unbounded re-arm never fires. Resets on visible.
if (
typeof document !== "undefined" &&
- document.visibilityState === "hidden"
+ document.visibilityState === "hidden" &&
+ this._hiddenRearmCount < this._maxHiddenRearms
) {
+ this._hiddenRearmCount += 1;
+ this.warn("[WCR] first-chunk watchdog re-armed while hidden", {
+ attempt: this._hiddenRearmCount,
+ max: this._maxHiddenRearms,
+ frameCount: this.frameCount,
+ });
this._armFirstChunkWatchdog();
return;
}
diff --git a/src/pages/Region/Recorder.jsx b/src/pages/Region/Recorder.jsx
index c80c9b8..c4de404 100644
--- a/src/pages/Region/Recorder.jsx
+++ b/src/pages/Region/Recorder.jsx
@@ -24,6 +24,7 @@ import {
import {
probeFastRecorderSupport,
shouldUseFastRecorder,
+ resolveFastRecorderUserSetting,
getFastRecorderStickyState,
markFastRecorderFailure,
validateFastRecorderOutputBlob,
@@ -919,8 +920,7 @@ const Recorder = () => {
const { useWebCodecsRecorder } = await chrome.storage.local.get([
"useWebCodecsRecorder",
]);
- // undefined defaults to enabled; only explicit `false` opts out.
- const userSetting = useWebCodecsRecorder === false ? false : true;
+ const userSetting = resolveFastRecorderUserSetting(useWebCodecsRecorder);
const stickyState = await getFastRecorderStickyState();
const probeResult = await probeFastRecorderSupport();
const shouldUseFast = shouldUseFastRecorder(
diff --git a/src/pages/utils/buildDiagnosticZip.js b/src/pages/utils/buildDiagnosticZip.js
index 8fde068..2e960bf 100644
--- a/src/pages/utils/buildDiagnosticZip.js
+++ b/src/pages/utils/buildDiagnosticZip.js
@@ -73,6 +73,25 @@ const FAST_RECORDER_KEYS = [
"lastSubscriptionLoss",
];
+// navigator.userAgent is reduced to Chrome/150.0.0.0; only the high-entropy
+// hints carry the real build.
+const readBrowserVersionDetail = async () => {
+ try {
+ const uaData = navigator.userAgentData;
+ if (!uaData?.getHighEntropyValues) return null;
+ const hints = await uaData.getHighEntropyValues([
+ "fullVersionList",
+ "platformVersion",
+ ]);
+ return {
+ fullVersionList: hints?.fullVersionList || null,
+ platformVersion: hints?.platformVersion || null,
+ };
+ } catch {
+ return null;
+ }
+};
+
export const buildDiagnosticZip = async ({
extraConfig = {},
source = "unknown",
@@ -138,6 +157,7 @@ export const buildDiagnosticZip = async ({
files["environment.json"] = JSON.stringify({
userAgent,
+ browserVersionDetail: await readBrowserVersionDetail(),
platformInfo,
screen: {
width: window.screen.availWidth,
diff --git a/src/pages/utils/buildSupportContext.js b/src/pages/utils/buildSupportContext.js
index 262eff0..917daad 100644
--- a/src/pages/utils/buildSupportContext.js
+++ b/src/pages/utils/buildSupportContext.js
@@ -31,6 +31,26 @@ const shortBrowser = () => {
return "Unknown";
};
+// shortBrowser() can only say Chrome/150; the high-entropy hint has the real
+// build. Brand order mirrors shortBrowser().
+const fullBrowserVersion = async () => {
+ try {
+ const uaData = navigator.userAgentData;
+ if (!uaData?.getHighEntropyValues) return null;
+ const { fullVersionList } = await uaData.getHighEntropyValues([
+ "fullVersionList",
+ ]);
+ if (!Array.isArray(fullVersionList)) return null;
+ for (const wanted of [/^Microsoft Edge$/i, /^Google Chrome$/i, /^Chromium$/i]) {
+ const hit = fullVersionList.find((b) => wanted.test(b?.brand || ""));
+ if (hit?.version) return String(hit.version);
+ }
+ return null;
+ } catch {
+ return null;
+ }
+};
+
/** Build support context. Returns flat key-value pairs for URLSearchParams. */
export const buildSupportContext = async (opts = {}) => {
const ctx = {};
@@ -38,6 +58,8 @@ export const buildSupportContext = async (opts = {}) => {
ctx.v = chrome.runtime.getManifest().version;
ctx.lang = chrome.i18n.getMessage("@@ui_locale") || "unknown";
ctx.br = shortBrowser();
+ const brFull = await fullBrowserVersion();
+ if (brFull) ctx.brFull = brFull;
// Coarse device class, to see if stuck-recording reports cluster on low-RAM
// or low-core devices. Both are already exposed to every page, no PII.
diff --git a/webpack.config.js b/webpack.config.js
index a9414df..3d6b509 100755
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -327,6 +327,11 @@ const config = {
to: path.join(__dirname, "build/_locales"),
force: true,
},
+ {
+ from: "THIRD_PARTY_NOTICES.md",
+ to: path.join(__dirname, "build/THIRD_PARTY_NOTICES.md"),
+ force: true,
+ },
],
}),
...htmlPlugins,