Skip to content

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

Fix recordings opening in wrong editor and improve recovery flow

Alyssa X14f8767e5b46
diff --git a/.gitignore b/.gitignore
index 6e4d643..f386b32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,6 @@ tests/
test-results/
playwright-report/
tools/diagnostics-viewer/
+scripts/cws-preflight.mjs
+scripts/cws-get-refresh-token.mjs
+scripts/cws-baseline.json
diff --git a/package-lock.json b/package-lock.json
index 3667e5d..c49c768 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -64,9 +64,11 @@
"@types/react-dom": "^18.3.7",
"babel-loader": "^9.1.3",
"browserstack-local": "^1.5.13",
+ "chrome-webstore-upload-cli": "^3.5.0",
"copy-webpack-plugin": "^7.0.0",
"cross-env": "^7.0.3",
"css-loader": "^6.7.2",
+ "dotenv-cli": "^11.0.0",
"fs-extra": "^10.1.0",
"html-loader": "^3.1.0",
"html-webpack-plugin": "^5.5.0",
@@ -5132,6 +5134,16 @@
"ieee754": "^1.2.1"
}
},
+ "node_modules/buffer-crc32": {
+ "version": "0.2.13",
+ "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
+ "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": "*"
+ }
+ },
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@@ -5319,6 +5331,55 @@
"node": ">=6.0"
}
},
+ "node_modules/chrome-webstore-upload": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/chrome-webstore-upload/-/chrome-webstore-upload-3.2.0.tgz",
+ "integrity": "sha512-ghFzqGFpPzEvDfam7qzokj07KsPn39fOdoj9KwqgQdjcHpFCJ1/wnKi2IHP6zCcHKWEBv9vI7VVbllbDRnypXw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/fregante"
+ }
+ },
+ "node_modules/chrome-webstore-upload-cli": {
+ "version": "3.5.0",
+ "resolved": "https://registry.npmjs.org/chrome-webstore-upload-cli/-/chrome-webstore-upload-cli-3.5.0.tgz",
+ "integrity": "sha512-cojgwXDLK+TbeUh8Ll+H33njdCtBPY3pmf2Y5++HWZwlsrmTaW9I8mQz7FS3N57qv/8Woz5TY+SwiUjFtKwsnA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "chrome-webstore-upload": "^3.2.0",
+ "junk": "^4.0.1",
+ "meow": "^12.1.1",
+ "recursive-readdir": "^2.2.3",
+ "yazl": "^2.5.1"
+ },
+ "bin": {
+ "chrome-webstore-upload": "cli.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/fregante"
+ }
+ },
+ "node_modules/chrome-webstore-upload-cli/node_modules/meow": {
+ "version": "12.1.1",
+ "resolved": "https://registry.npmjs.org/meow/-/meow-12.1.1.tgz",
+ "integrity": "sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=16.10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/ci-info": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz",
@@ -6211,6 +6272,51 @@
"url": "https://dotenvx.com"
}
},
+ "node_modules/dotenv-cli": {
+ "version": "11.0.0",
+ "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-11.0.0.tgz",
+ "integrity": "sha512-r5pA8idbk7GFWuHEU7trSTflWcdBpQEK+Aw17UrSHjS6CReuhrrPcyC3zcQBPQvhArRHnBo/h6eLH1fkCvNlww==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "cross-spawn": "^7.0.6",
+ "dotenv": "^17.1.0",
+ "dotenv-expand": "^12.0.0",
+ "minimist": "^1.2.6"
+ },
+ "bin": {
+ "dotenv": "cli.js"
+ }
+ },
+ "node_modules/dotenv-expand": {
+ "version": "12.0.3",
+ "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-12.0.3.tgz",
+ "integrity": "sha512-uc47g4b+4k/M/SeaW1y4OApx+mtLWl92l5LMPP0GNXctZqELk+YGgOPIIC5elYmUH4OuoK3JLhuRUYegeySiFA==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "dotenv": "^16.4.5"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://dotenvx.com"
+ }
+ },
+ "node_modules/dotenv-expand/node_modules/dotenv": {
+ "version": "16.6.1",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
+ "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://dotenvx.com"
+ }
+ },
"node_modules/driver.js": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/driver.js/-/driver.js-1.4.0.tgz",
@@ -8065,6 +8171,19 @@
"setimmediate": "^1.0.5"
}
},
+ "node_modules/junk": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/junk/-/junk-4.0.1.tgz",
+ "integrity": "sha512-Qush0uP+G8ZScpGMZvHUiRfI0YBWuB3gVBYlI0v0vvOJt5FLicco+IkP0a50LqTTQhmts/m6tP5SWE+USyIvcQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/keyv": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz",
@@ -9878,6 +9997,19 @@
"node": ">= 10.13.0"
}
},
+ "node_modules/recursive-readdir": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz",
+ "integrity": "sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "minimatch": "^3.0.5"
+ },
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
"node_modules/regenerate": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
@@ -12177,6 +12309,16 @@
"node": ">=12"
}
},
+ "node_modules/yazl": {
+ "version": "2.5.1",
+ "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz",
+ "integrity": "sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "buffer-crc32": "~0.2.3"
+ }
+ },
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
diff --git a/package.json b/package.json
index 079404f..d37e070 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "screenity",
- "version": "4.4.0",
+ "version": "4.4.2",
"description": "The free and privacy-friendly screen recorder with no sign in needed.",
"scripts": {
"build": "cross-env NODE_ENV=development node utils/build.js",
@@ -15,6 +15,14 @@
"postinstall": "patch-package && node scripts/patch-radix.js",
"package": "npm run build:prod && cd build && zip -r ../extension.zip . && cd ..",
"package:release": "npm run build:release && cd build && zip -r ../extension.zip . && cd ..",
+ "build:cws": "npm run build:prod && cd build && zip -r ../build-cws.zip . && cd ..",
+ "preflight:cws": "node scripts/cws-preflight.mjs",
+ "preflight:cws:bless": "node scripts/cws-preflight.mjs --bless",
+ "release:cws": "npm run build:cws && npm run preflight:cws && dotenv -e .env.local -- chrome-webstore-upload upload --source build-cws.zip",
+ "release:cws:force": "npm run build:cws && node scripts/cws-preflight.mjs --confirm && dotenv -e .env.local -- chrome-webstore-upload upload --source build-cws.zip",
+ "release:cws:publish": "dotenv -e .env.local -- chrome-webstore-upload publish",
+ "release:cws:publish:10": "dotenv -e .env.local -- chrome-webstore-upload publish --deploy-percentage 10",
+ "release:cws:publish:50": "dotenv -e .env.local -- chrome-webstore-upload publish --deploy-percentage 50",
"clean": "rm -rf build && mkdir build",
"lint": "eslint src/**/*.js --fix",
"build:content-css": "sass src/pages/Content/styles/app.scss src/pages/Content/styles/app.css --no-source-map",
@@ -78,9 +86,11 @@
"@types/react-dom": "^18.3.7",
"babel-loader": "^9.1.3",
"browserstack-local": "^1.5.13",
+ "chrome-webstore-upload-cli": "^3.5.0",
"copy-webpack-plugin": "^7.0.0",
"cross-env": "^7.0.3",
"css-loader": "^6.7.2",
+ "dotenv-cli": "^11.0.0",
"fs-extra": "^10.1.0",
"html-loader": "^3.1.0",
"html-webpack-plugin": "^5.5.0",
diff --git a/src/manifest.json b/src/manifest.json
index a87fdf1..f79a278 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -3,7 +3,7 @@
"name": "__MSG_extName__",
"description": "__MSG_extDesc__",
"default_locale": "en",
- "version": "4.4.0",
+ "version": "4.4.2",
"background": {
"service_worker": "background.bundle.js"
},
@@ -13,12 +13,20 @@
"icons": {
"128": "assets/img/icon-128.png"
},
- "host_permissions": ["<all_urls>"],
+ "host_permissions": [
+ "<all_urls>"
+ ],
"content_scripts": [
{
- "matches": ["<all_urls>"],
- "js": ["contentScript.bundle.js"],
- "css": ["assets/fonts/fonts.css"]
+ "matches": [
+ "<all_urls>"
+ ],
+ "js": [
+ "contentScript.bundle.js"
+ ],
+ "css": [
+ "assets/fonts/fonts.css"
+ ]
}
],
"web_accessible_resources": [
@@ -46,12 +54,16 @@
"download.html",
"*"
],
- "matches": ["<all_urls>"]
+ "matches": [
+ "<all_urls>"
+ ]
}
],
"oauth2": {
"client_id": "560517327251-m7n1k3kddknu7s9s4ejvrs1bj91gutd7.apps.googleusercontent.com",
- "scopes": ["https://www.googleapis.com/auth/drive.file"]
+ "scopes": [
+ "https://www.googleapis.com/auth/drive.file"
+ ]
},
"cross_origin_embedder_policy": {
"value": "require-corp"
@@ -64,7 +76,9 @@
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; media-src 'self' data: blob: *; img-src 'self' https: data: blob:"
},
"sandbox": {
- "pages": ["editor.html"]
+ "pages": [
+ "editor.html"
+ ]
},
"commands": {
"start-recording": {
@@ -116,7 +130,10 @@
"managed_schema": "schema.json"
},
"externally_connectable": {
- "matches": ["https://app.screenity.io/*", "http://localhost:3000/*"]
+ "matches": [
+ "https://app.screenity.io/*",
+ "http://localhost:3000/*"
+ ]
},
"optional_permissions": [
"offscreen",
diff --git a/src/pages/Background/messaging/handlers.js b/src/pages/Background/messaging/handlers.js
index fb775d9..5fd6338 100644
--- a/src/pages/Background/messaging/handlers.js
+++ b/src/pages/Background/messaging/handlers.js
@@ -1469,12 +1469,13 @@ export const setupHandlers = () => {
registerMessage("open-home", () =>
createTab("https://screenity.io/", false, true),
);
- registerMessage("report-bug", async () => {
+ registerMessage("report-bug", async (message) => {
const qs = await supportContextQuery({
includeRecordingState: true,
source: "settings",
});
- createTab(`https://tally.so/r/3ElpXq?${qs}`, false, true);
+ const zipParam = message?.zipBundled ? "&zipBundled=1" : "";
+ createTab(`https://tally.so/r/3ElpXq?${qs}${zipParam}`, false, true);
});
registerMessage("report-error", async (message) => {
const errorCode = message?.errorCode || null;
@@ -1501,10 +1502,11 @@ export const setupHandlers = () => {
user: isLoggedIn ? { name: user.name, email: user.email } : undefined,
});
+ const zipParam = message?.zipBundled ? "&zipBundled=1" : "";
if (isLoggedIn) {
createTab(`https://tally.so/r/310MNg?extension=true&${qs}`, false, true);
} else {
- createTab(`https://tally.so/r/3ElpXq?feedbackType=Bug&${qs}`, false, true);
+ createTab(`https://tally.so/r/3ElpXq?feedbackType=Bug&${qs}${zipParam}`, false, true);
}
});
registerMessage("clear-recordings", () => clearAllRecordings());
diff --git a/src/pages/Background/recording/openRecorderTab.js b/src/pages/Background/recording/openRecorderTab.js
index 4b3534f..29529d3 100644
--- a/src/pages/Background/recording/openRecorderTab.js
+++ b/src/pages/Background/recording/openRecorderTab.js
@@ -63,14 +63,19 @@ const openRecorderTab = async (
const finalUrl = isRegion ? `${recorderUrl}?tab=true` : recorderUrl;
- // Close any leftover setup.html: a user starting cloud recording has
- // moved past onboarding, and if it's still open it tends to steal focus
- // back from the editor when the recorder tab closes post-stop.
+ // Close leftover setup.html tabs to prevent them stealing focus from
+ // the editor after recording stops. Skip the active source tab: a
+ // freshly-installed user can click Record directly from setup.html,
+ // and closing the source tab mid-acquisition fires REC_START_SOURCE_TAB_GONE.
try {
const setupUrl = chrome.runtime.getURL("setup.html");
const allTabs = await chrome.tabs.query({});
const stale = allTabs.filter(
- (t) => t.id != null && t.url && t.url.startsWith(setupUrl),
+ (t) =>
+ t.id != null &&
+ t.id !== activeTab?.id &&
+ t.url &&
+ t.url.startsWith(setupUrl),
);
if (stale.length > 0) {
await chrome.tabs.remove(stale.map((t) => t.id));
diff --git a/src/pages/Background/recording/restoreRecording.js b/src/pages/Background/recording/restoreRecording.js
index 4e45646..59fd5d3 100644
--- a/src/pages/Background/recording/restoreRecording.js
+++ b/src/pages/Background/recording/restoreRecording.js
@@ -77,10 +77,6 @@ export const checkRestore = async () => {
};
export const restoreRecording = async () => {
- const { fastRecorderInUse } = await chrome.storage.local.get([
- "fastRecorderInUse",
- ]);
-
// capture trigger tab now; restore can take 30s+ and the user may switch
let triggerTabId = null;
try {
@@ -138,10 +134,12 @@ export const restoreRecording = async () => {
return;
}
- // IDB fallback: MediaRecorder + pre-4.4.0 WebCodecs.
- // Duration estimate routes between editor.html (short, ffmpeg) and viewer (long).
- // Priority: recordingDuration (clean stop) > lastChunkAt-firstChunkAt (survives SW death).
- const hasWebCodecs = Boolean(fastRecorderInUse);
+ // IDB fallback: MediaRecorder produces IDB chunks. WebCodecs (4.4.0+) writes
+ // OPFS, which was already handled above. Routing here is purely IDB:
+ // editor.html for short, editorviewer.html for long. Reading fastRecorderInUse
+ // here was a stale-flag hazard β€” a crashed WebCodecs session can leave it
+ // true while no OPFS file ever made it to disk, which would route to
+ // editorwebcodecs.html and find nothing.
const {
recordingDuration,
firstChunkAt,
@@ -159,10 +157,7 @@ export const restoreRecording = async () => {
const FFMPEG_MAX_DURATION_MS = 7 * 60 * 1000;
let editorUrl, messageType;
- if (hasWebCodecs) {
- editorUrl = "editorwebcodecs.html?mode=recover";
- messageType = "restore-recording";
- } else if (durationMs > 0 && durationMs <= FFMPEG_MAX_DURATION_MS) {
+ if (durationMs > 0 && durationMs <= FFMPEG_MAX_DURATION_MS) {
// ffmpeg-wasm cap: editLimit:600
editorUrl = "editor.html?mode=recover";
messageType = "fallback-recording";
diff --git a/src/pages/Background/recording/startRecording.js b/src/pages/Background/recording/startRecording.js
index 16ba666..407b221 100644
--- a/src/pages/Background/recording/startRecording.js
+++ b/src/pages/Background/recording/startRecording.js
@@ -142,6 +142,8 @@ const _startRecordingInner = async (caller) => {
memoryError: false,
cloudRecorderDegradedMode: null,
editorRecordingError: null,
+ editorReadyAt: null,
+ editorReadyPath: 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/Background/recording/stopRecording.js b/src/pages/Background/recording/stopRecording.js
index 8a36faa..108fd90 100644
--- a/src/pages/Background/recording/stopRecording.js
+++ b/src/pages/Background/recording/stopRecording.js
@@ -148,10 +148,12 @@ export const stopRecording = async () => {
fastRecorderInUse,
fastRecorderActiveRecordingId,
fastRecorderValidation,
+ lastRecordingBackendRef,
} = await chrome.storage.local.get([
"fastRecorderInUse",
"fastRecorderActiveRecordingId",
"fastRecorderValidation",
+ "lastRecordingBackendRef",
]);
const validation =
fastRecorderValidation && typeof fastRecorderValidation === "object"
@@ -161,7 +163,19 @@ export const stopRecording = async () => {
validation?.details?.recordingId &&
validation.details.recordingId === fastRecorderActiveRecordingId;
const hardFailForCurrent = Boolean(validationMatches && validation?.hardFail);
- const hasWebCodecs = Boolean(fastRecorderInUse) && !hardFailForCurrent;
+ // Route by where the bytes actually live: editor.html is sandboxed and
+ // can't read OPFS, so OPFS-backed recordings MUST go to editorwebcodecs.html
+ // regardless of which encoder produced them. fastRecorderInUse is the encoder
+ // flag, not a storage flag, and the two can diverge on probe/validation
+ // fallback. Backend is ground truth.
+ const bytesInOpfs = lastRecordingBackendRef?.backend === "opfs";
+ const hasWebCodecs = bytesInOpfs;
+ diagEvent("editor-route-decision", {
+ backend: lastRecordingBackendRef?.backend || null,
+ fastRecorderInUse: Boolean(fastRecorderInUse),
+ hardFailForCurrent,
+ route: hasWebCodecs ? "webcodecs" : "ffmpeg",
+ });
const {
postStopEditorOpened,
@@ -339,9 +353,53 @@ export const stopRecording = async () => {
chrome.runtime.sendMessage({ type: "turn-off-pip" });
}
+ // Hold the diag session open until editorReadyAt lands or 90s passes
+ // so sandbox-side events from the editor load make it into the zip.
+ // Closing here used to drop everything past stop+~17ms.
// never clear recordingTab here; cleanup runs in handleRecordingComplete /
// onTabRemoved / openRecorderTab safety net
- endDiagSession("ok");
+ (async () => {
+ const SESSION_DEFER_TIMEOUT_MS = 90_000;
+ const POLL_INTERVAL_MS = 500;
+ // Snapshot baseline so a stale editorReadyAt from a prior session
+ // doesn't immediately satisfy the wait.
+ const baseline = await chrome.storage.local
+ .get(["editorReadyAt"])
+ .catch(() => ({}));
+ const baselineAt = baseline?.editorReadyAt || 0;
+ const start = Date.now();
+ while (Date.now() - start < SESSION_DEFER_TIMEOUT_MS) {
+ try {
+ const r = await chrome.storage.local.get([
+ "editorReadyAt",
+ "editorRecordingError",
+ ]);
+ const readyAt = r?.editorReadyAt || 0;
+ if (readyAt > baselineAt) {
+ diagEvent("session-deferred-end", {
+ reason: "editor-ready",
+ waitedMs: Date.now() - start,
+ });
+ break;
+ }
+ if (r?.editorRecordingError) {
+ diagEvent("session-deferred-end", {
+ reason: "editor-error",
+ waitedMs: Date.now() - start,
+ });
+ break;
+ }
+ } catch {}
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
+ }
+ if (Date.now() - start >= SESSION_DEFER_TIMEOUT_MS) {
+ diagEvent("session-deferred-end", {
+ reason: "timeout",
+ waitedMs: SESSION_DEFER_TIMEOUT_MS,
+ });
+ }
+ endDiagSession("ok");
+ })();
const { wasRegion } = await chrome.storage.local.get(["wasRegion"]);
if (wasRegion) {
@@ -385,6 +443,7 @@ export const handleStopRecordingTab = async (request) => {
totalPausedMs,
fastRecorderInUse,
fastRecorderActiveRecordingId,
+ lastRecordingBackendRef,
} = await chrome.storage.local.get([
"isSubscribed",
"recordingStartTime",
@@ -393,8 +452,19 @@ export const handleStopRecordingTab = async (request) => {
"totalPausedMs",
"fastRecorderInUse",
"fastRecorderActiveRecordingId",
+ "lastRecordingBackendRef",
]);
endStorageGet1();
+ // Same rule as handleRecordingComplete: route by backend, not by the
+ // encoder flag. fastRecorderInUse can lie when WebCodecs fell back to MR
+ // mid-pipeline (probe disagreement, in-session swap). Bytes location wins.
+ const bytesInOpfs = lastRecordingBackendRef?.backend === "opfs";
+ diagEvent("editor-route-decision", {
+ via: "stop-tab",
+ backend: lastRecordingBackendRef?.backend || null,
+ fastRecorderInUse: Boolean(fastRecorderInUse),
+ route: bytesInOpfs ? "webcodecs" : "ffmpeg",
+ });
const stopTabNow = Date.now();
const stopTabStartTime = Number(recordingStartTime);
const stopTabBasePaused = Number(totalPausedMs) || 0;
@@ -442,7 +512,7 @@ export const handleStopRecordingTab = async (request) => {
return;
}
- if (fastRecorderInUse) {
+ if (bytesInOpfs) {
diagEvent("editor-open", { type: "editorwebcodecs", via: "stop-tab" });
const editorUrl = "editorwebcodecs.html";
// Open editor immediately in postStop mode (WebCodecs only)
diff --git a/src/pages/Content/context/ContentState.jsx b/src/pages/Content/context/ContentState.jsx
index 7e1487a..3380002 100644
--- a/src/pages/Content/context/ContentState.jsx
+++ b/src/pages/Content/context/ContentState.jsx
@@ -22,6 +22,7 @@ import {
traceStep,
setStartFlowOutcome,
} from "../../utils/startFlowTrace";
+import { triggerSupportDownload } from "../../utils/triggerSupportDownload";
export const contentStateContext = createContext();
export const contentStateRef = { current: null };
@@ -627,10 +628,12 @@ const ContentState = (props) => {
false,
chrome.i18n.getMessage("getHelpButton"),
() => {
+ triggerSupportDownload({ source: "not-enough-space" });
chrome.runtime.sendMessage({
type: "report-error",
errorCode: "REC_RUN_MEMORY",
source: "not-enough-space",
+ zipBundled: true,
});
},
);
diff --git a/src/pages/Content/context/messaging/handlers.js b/src/pages/Content/context/messaging/handlers.js
index f34326c..a940cad 100644
--- a/src/pages/Content/context/messaging/handlers.js
+++ b/src/pages/Content/context/messaging/handlers.js
@@ -8,6 +8,7 @@ import { updateFromStorage } from "../utils/updateFromStorage";
import { checkAuthStatus } from "../utils/checkAuthStatus";
import { traceStep, setStartFlowOutcome } from "../../../utils/startFlowTrace";
import { perfMark } from "../../../utils/perfMarks";
+import { triggerSupportDownload } from "../../../utils/triggerSupportDownload";
import JSZip from "jszip";
const CLOUD_FEATURES_ENABLED =
@@ -622,6 +623,20 @@ export const setupHandlers = () => {
null,
() => {},
() => {},
+ null,
+ null,
+ null,
+ false,
+ chrome.i18n.getMessage("getHelpButton"),
+ () => {
+ triggerSupportDownload({ source: "recording-failed" });
+ chrome.runtime.sendMessage({
+ type: "report-error",
+ source: "recording-failed",
+ errorCode: "REC_START_FAILED",
+ zipBundled: true,
+ });
+ },
);
}
});
@@ -764,11 +779,13 @@ export const setupHandlers = () => {
false,
chrome.i18n.getMessage("getHelpButton"),
() => {
+ triggerSupportDownload({ source: "stream-error" });
chrome.runtime.sendMessage({
type: "report-error",
errorCode,
errorWhy,
source: "stream-error",
+ zipBundled: true,
});
},
);
@@ -805,6 +822,20 @@ export const setupHandlers = () => {
() => {
state.dismissRecording();
},
+ null,
+ null,
+ null,
+ false,
+ chrome.i18n.getMessage("getHelpButton"),
+ () => {
+ triggerSupportDownload({ source: "backup-error" });
+ chrome.runtime.sendMessage({
+ type: "report-error",
+ source: "backup-error",
+ errorCode: "BACKUP_PERMISSION_FAILED",
+ zipBundled: true,
+ });
+ },
);
});
@@ -895,8 +926,16 @@ export const setupHandlers = () => {
null,
null,
true,
- false,
- () => {},
+ chrome.i18n.getMessage("getHelpButton"),
+ () => {
+ triggerSupportDownload({ source: "fast-recorder-hard-fail" });
+ chrome.runtime.sendMessage({
+ type: "report-error",
+ source: "fast-recorder-hard-fail",
+ errorCode: "FAST_RECORDER_HARD_FAIL",
+ zipBundled: true,
+ });
+ },
);
});
diff --git a/src/pages/Download/Download.jsx b/src/pages/Download/Download.jsx
index 7830f65..e7c6ea2 100644
Binary files a/src/pages/Download/Download.jsx and b/src/pages/Download/Download.jsx differ
diff --git a/src/pages/Recorder/Recorder.jsx b/src/pages/Recorder/Recorder.jsx
index 0f99adb..b5ee53a 100644
--- a/src/pages/Recorder/Recorder.jsx
+++ b/src/pages/Recorder/Recorder.jsx
@@ -1176,29 +1176,39 @@ const Recorder = () => {
});
endActiveSet();
- // Chunk backend: fall back to IDB if OPFS open() fails. Prefer IDB up-front
- // when WebCodecs is skipped: the legacy editor's sandboxed iframe lacks
- // allow-same-origin and can't read OPFS.
- const endStickyRead = perfSpan("Recorder.preflight getStickyState");
- const earlyStickyState = await getFastRecorderStickyState();
- endStickyRead();
- const willLikelyUseFast =
- prefUseWebCodecs !== false &&
- !(earlyStickyState?.disabled && prefUseWebCodecs !== true);
+ // Decide encoder BEFORE opening the writer. The previous code used an
+ // optimistic guess (willLikelyUseFast) based on user pref + sticky state
+ // only; when the actual probe disagreed (e.g. Linux Chrome with broken
+ // VideoEncoder coverage), MediaRecorder ran but bytes had already started
+ // flowing into the OPFS writer that was opened against the guess. The
+ // sandboxed editor.html then couldn't read OPFS. Backend choice is now
+ // a function of shouldUseFast, the ground truth.
+ const { useWebCodecsRecorder } = await chrome.storage.local.get([
+ "useWebCodecsRecorder",
+ ]);
+ // Default-on: undefined means enabled; only explicit `false` opts out.
+ const userSetting = useWebCodecsRecorder === false ? false : true;
+ const stickyState = await getFastRecorderStickyState();
+ const probeResult = await probeFastRecorderSupport();
+ const shouldUseFast = shouldUseFastRecorder(
+ userSetting,
+ probeResult,
+ stickyState,
+ );
chunkWriter.current = null;
chunkWriterBackend.current = null;
if (process.env.SCREENITY_DEV_MODE === "true") {
console.log("[recorder-opfs][recorder] chooseWriter entry", {
recordingId,
- willLikelyUseFast,
+ shouldUseFast,
});
}
try {
const endChoose = perfSpan("Recorder.preflight chooseWriter");
let selection;
let openResult = null;
- const wantBackend = willLikelyUseFast ? "opfs" : "idb";
+ const wantBackend = shouldUseFast ? "opfs" : "idb";
const prewarmedMatches =
prewarmedWriter && prewarmedWriter.selection.backend === wantBackend;
if (prewarmedMatches) {
@@ -1208,7 +1218,7 @@ const Recorder = () => {
if (prewarmedWriter?.selection?.writer?.abort) {
prewarmedWriter.selection.writer.abort().catch(() => {});
}
- selection = await chooseWriter({ preferOpfs: willLikelyUseFast });
+ selection = await chooseWriter({ preferOpfs: shouldUseFast });
}
endChoose({ backend: selection?.backend, prewarmed: prewarmedMatches });
if (process.env.SCREENITY_DEV_MODE === "true") {
@@ -1276,19 +1286,6 @@ const Recorder = () => {
});
} catch {}
}
-
- const { useWebCodecsRecorder } = await chrome.storage.local.get([
- "useWebCodecsRecorder",
- ]);
- // Default-on: undefined means enabled; only explicit `false` opts out.
- const userSetting = useWebCodecsRecorder === false ? false : true;
- const stickyState = await getFastRecorderStickyState();
- const probeResult = await probeFastRecorderSupport();
- const shouldUseFast = shouldUseFastRecorder(
- userSetting,
- probeResult,
- stickyState,
- );
const selectedVideoConfig =
probeResult?.details?.selectedVideoConfig || null;
@@ -1828,6 +1825,16 @@ const Recorder = () => {
try {
prev?.cleanup?.();
} catch {}
+ // Abort the OPFS writer so the re-entered startRecording opens
+ // a fresh IDB one. Without this, MR bytes would stream into
+ // OPFS and the editor.html sandbox couldn't read them.
+ if (chunkWriter.current) {
+ try {
+ await chunkWriter.current.abort();
+ } catch {}
+ chunkWriter.current = null;
+ chunkBackendRef.current = null;
+ }
// Re-enter startRecording (guard at top requires both
// recorder.current null and isStarting.current false).
isStarting.current = false;
@@ -1898,6 +1905,17 @@ const Recorder = () => {
message: chrome.i18n.getMessage("webcodecsFailedOffToast"),
});
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.
+ if (chunkWriter.current) {
+ try {
+ await chunkWriter.current.abort();
+ } catch {}
+ chunkWriter.current = null;
+ chunkBackendRef.current = null;
+ }
// Top-of-startRecording guard requires both recorder null AND
// isStarting false; without this reset the recursive call bails.
isStarting.current = false;
diff --git a/src/pages/Recorder/recorderStorage/opfs/opfsChunkWriter.js b/src/pages/Recorder/recorderStorage/opfs/opfsChunkWriter.js
index d0fd103..217623f 100644
--- a/src/pages/Recorder/recorderStorage/opfs/opfsChunkWriter.js
+++ b/src/pages/Recorder/recorderStorage/opfs/opfsChunkWriter.js
@@ -191,11 +191,10 @@ export class OpfsChunkWriter {
byteSize: this._byteSize,
chunkCount: this._chunkCount,
});
- // signal "file is fully flushed" to the sandbox reader. kept as its
- // own key because stop cleanup rewrites lastRecordingBackendRef from
- // a few different paths and would clobber a finalized flag stored
- // there. without this signal the editor reads mid-flush and ends up
- // with a truncated blob.
+ } finally {
+ // Always set the finalized flag, even if close() timed out or
+ // threw. Writing it only on success left the editor's wait-finalize
+ // loop spinning 60s on slow disks (AV scan, hung worker).
if (this._fileName) {
try {
await chrome.storage.local.set({
@@ -203,7 +202,6 @@ export class OpfsChunkWriter {
});
} catch {}
}
- } finally {
this._closed = true;
this._teardown();
}
diff --git a/src/pages/Region/Recorder.jsx b/src/pages/Region/Recorder.jsx
index 6475a8b..3f16e53 100644
--- a/src/pages/Region/Recorder.jsx
+++ b/src/pages/Region/Recorder.jsx
@@ -1234,6 +1234,18 @@ const Recorder = () => {
lastWebCodecsFailureAt: Date.now(),
lastWebCodecsFailureCode: "start-failed",
});
+ // The OPFS writer was opened for the WebCodecs path. If we let it
+ // hang around, startMediaRecorderWithCodec's no-existing-writer guard
+ // would reuse it, sending MediaRecorder bytes into OPFS where the
+ // sandboxed editor can't read them. Abort here so the MR path opens
+ // a fresh IDB writer.
+ if (chunkWriter.current) {
+ try {
+ await chunkWriter.current.abort();
+ } catch {}
+ chunkWriter.current = null;
+ chunkBackendRef.current = null;
+ }
chrome.runtime.sendMessage({
type: "show-toast",
message: chrome.i18n.getMessage("webcodecsFailedOffToast"),
@@ -1284,28 +1296,37 @@ const Recorder = () => {
videoBitsPerSecond: videoBitsPerSecond,
});
- // Force IDB: MediaRecorder chunks must relay to null-origin sandbox.
- if (!chunkWriter.current) {
+ // Force IDB: MediaRecorder chunks must relay to the null-origin sandbox
+ // editor, which cannot read OPFS. Always replace whatever is in
+ // chunkWriter.current β€” if WebCodecs opened an OPFS writer earlier and
+ // then fell back to us, leaving the OPFS writer in place would silently
+ // route MR bytes into OPFS and strand them.
+ if (chunkWriter.current) {
try {
- const selection = await chooseWriter({ preferOpfs: false });
- chunkWriter.current = selection.writer;
- const openResult = await chunkWriter.current.open(
- `region-mr-${Date.now()}-${Math.random()
- .toString(36)
- .slice(2, 8)}`,
- );
- const backendRefAtOpen = openResult?.backendRef || {
- backend: "idb",
- };
- chunkBackendRef.current = backendRefAtOpen;
- try {
- await chrome.storage.local.set({
- lastRecordingBackendRef: backendRefAtOpen,
- });
- } catch {}
- } catch (err) {
- chunkWriter.current = null;
- }
+ await chunkWriter.current.abort();
+ } catch {}
+ chunkWriter.current = null;
+ chunkBackendRef.current = null;
+ }
+ try {
+ const selection = await chooseWriter({ preferOpfs: false });
+ chunkWriter.current = selection.writer;
+ const openResult = await chunkWriter.current.open(
+ `region-mr-${Date.now()}-${Math.random()
+ .toString(36)
+ .slice(2, 8)}`,
+ );
+ const backendRefAtOpen = openResult?.backendRef || {
+ backend: "idb",
+ };
+ chunkBackendRef.current = backendRefAtOpen;
+ try {
+ await chrome.storage.local.set({
+ lastRecordingBackendRef: backendRefAtOpen,
+ });
+ } catch {}
+ } catch (err) {
+ chunkWriter.current = null;
}
debug("MediaRecorder config", {
mimeType: recorder.current?.mimeType,
diff --git a/src/pages/Sandbox/Sandbox.jsx b/src/pages/Sandbox/Sandbox.jsx
index 196f538..21a9a58 100644
--- a/src/pages/Sandbox/Sandbox.jsx
+++ b/src/pages/Sandbox/Sandbox.jsx
@@ -12,11 +12,14 @@ import HelpButton from "./components/player/HelpButton";
import { ContentStateContext } from "./context/ContentState";
import { diagForward } from "../utils/diagForward";
import { perfMark } from "../utils/perfMarks";
+import { triggerSupportDownload } from "../utils/triggerSupportDownload";
const Sandbox = () => {
const [contentState, setContentState] = useContext(ContentStateContext);
const parentRef = useRef(null);
const progress = useRef("");
+ // ref so the stuck-timer closure (deps=[]) can read current state
+ const loadStateRef = useRef({ ready: false, hasBlob: false });
const getChromeVersion = () => {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
@@ -96,6 +99,11 @@ const Sandbox = () => {
}
}, [contentState.chunkIndex, contentState.chunkCount]);
+ useEffect(() => {
+ loadStateRef.current.ready = Boolean(contentState.ready);
+ loadStateRef.current.hasBlob = Boolean(contentState.blob);
+ }, [contentState.ready, contentState.blob]);
+
useEffect(() => {
chrome.runtime.sendMessage({ type: "check-banner-support" }, (response) => {
if (response && response.bannerSupport) {
@@ -155,8 +163,23 @@ const Sandbox = () => {
const stuckTimer = setTimeout(() => {
try {
if (cancelled) return;
- // editorRecordingError's own filter (ready=true β†’ suppress) makes
- // a stale write harmless if the editor already loaded.
+ // Skip the write if the editor finished. A bogus
+ // EDITOR_STUCK_TIMEOUT in diag zips makes the signal useless for
+ // telling real hangs from slow-but-fine.
+ if (loadStateRef.current.ready || loadStateRef.current.hasBlob) {
+ chrome.runtime
+ .sendMessage({
+ type: "diag-forward",
+ event: "sandbox-stuck-timeout-suppressed",
+ data: {
+ afterMs: STUCK_TIMEOUT_MS,
+ ready: loadStateRef.current.ready,
+ hasBlob: loadStateRef.current.hasBlob,
+ },
+ })
+ .catch(() => {});
+ return;
+ }
chrome.runtime
.sendMessage({
type: "diag-forward",
@@ -241,7 +264,8 @@ const Sandbox = () => {
chrome.runtime.sendMessage({ type: "restore-recording" });
},
() => {
- chrome.runtime.sendMessage({ type: "report-bug" });
+ triggerSupportDownload({ source: "sandbox-report-bug" });
+ chrome.runtime.sendMessage({ type: "report-bug", zipBundled: true });
},
null,
null,
@@ -249,9 +273,11 @@ const Sandbox = () => {
false,
chrome.i18n.getMessage("getHelpButton"),
() => {
+ triggerSupportDownload({ source: "processing-stuck" });
chrome.runtime.sendMessage({
type: "report-error",
source: "processing-stuck",
+ zipBundled: true,
});
},
);
diff --git a/src/pages/Sandbox/context/ContentState.jsx b/src/pages/Sandbox/context/ContentState.jsx
index a55df2a..6b7c66a 100644
--- a/src/pages/Sandbox/context/ContentState.jsx
+++ b/src/pages/Sandbox/context/ContentState.jsx
@@ -23,6 +23,7 @@ import {
} from "../../utils/recordingDebug";
import { diagForward } from "../../utils/diagForward";
import { perfMark, perfSpan } from "../../utils/perfMarks";
+import { triggerSupportDownload } from "../../utils/triggerSupportDownload";
import { chooseReader } from "../recorderStorage/chooseReader";
import {
Input,
@@ -262,6 +263,14 @@ const ContentState = (props) => {
chrome.runtime
.sendMessage({ type: "diag-editor-ready", path })
.catch(() => {});
+ // Mirror to storage so BG's deferred endDiagSession watcher can see
+ // ready without depending on the diag session being open.
+ try {
+ chrome.storage.local.set({
+ editorReadyAt: Date.now(),
+ editorReadyPath: path,
+ });
+ } catch {}
}, [contentState.ready]);
useEffect(() => {
@@ -774,12 +783,20 @@ const ContentState = (props) => {
const video = document.createElement("video");
video.preload = "metadata";
+ const videoLoadStart = Date.now();
video.onloadedmetadata = () => {
perfMark("Sandbox video-loadedmetadata", {
duration: video.duration,
w: video.videoWidth,
h: video.videoHeight,
});
+ diagForward("sandbox-video-loadedmetadata", {
+ elapsedMs: Date.now() - videoLoadStart,
+ duration: Number.isFinite(video.duration) ? video.duration : null,
+ width: video.videoWidth,
+ height: video.videoHeight,
+ blobBytes: blob?.size ?? 0,
+ });
setContentState((prev) => ({
...prev,
duration: video.duration,
@@ -790,6 +807,14 @@ const ContentState = (props) => {
URL.revokeObjectURL(video.src);
};
video.onerror = () => {
+ const errCode = video.error?.code ?? null;
+ const errMessage = video.error?.message ?? null;
+ diagForward("sandbox-video-load-error", {
+ elapsedMs: Date.now() - videoLoadStart,
+ code: errCode,
+ message: errMessage ? String(errMessage).slice(0, 200) : null,
+ blobBytes: blob?.size ?? 0,
+ });
diagForward("sandbox-reconstruct-error", {
error: "video-element-error",
phase: "video-load",
@@ -799,6 +824,9 @@ const ContentState = (props) => {
};
try {
video.src = URL.createObjectURL(blob);
+ diagForward("sandbox-video-src-set", {
+ blobBytes: blob?.size ?? 0,
+ });
} catch (err) {
diagForward("sandbox-reconstruct-error", {
error: String(err?.message || err).slice(0, 200),
@@ -1030,10 +1058,12 @@ const ContentState = (props) => {
false, // colorSafe
chrome.i18n.getMessage("getHelpButton"),
() => {
+ triggerSupportDownload({ source: "memory-limit" });
chrome.runtime.sendMessage({
type: "report-error",
errorCode: "REC_RUN_MEMORY",
source: "memory-limit",
+ zipBundled: true,
});
},
);
@@ -1153,28 +1183,71 @@ const ContentState = (props) => {
}));
if (lastRecordingBackendRef?.backend === "opfs") {
const reader = chooseReader(lastRecordingBackendRef);
+ const readerOpenStart = Date.now();
await reader.open(lastRecordingBackendRef);
+ diagForward("sandbox-opfs-reader-open-done", {
+ elapsedMs: Date.now() - readerOpenStart,
+ fileName: lastRecordingBackendRef?.fileName || null,
+ });
+ const readBlobStart = Date.now();
+ diagForward("sandbox-opfs-readblob-start", {});
const { blob: rawBlob } = await reader.readBlob({
// OPFS file isn't ready yet, recorder still flushing under load.
// Surface a labeled loading state so the user knows it's progressing.
onSlowFinalize: () => {
+ diagForward("sandbox-opfs-readblob-slow-finalize", {
+ elapsedMs: Date.now() - readBlobStart,
+ });
setContentState((prev) =>
prev.finalizingRecording ? prev : { ...prev, finalizingRecording: true },
);
},
});
+ diagForward("sandbox-opfs-readblob-done", {
+ elapsedMs: Date.now() - readBlobStart,
+ rawBlobBytes: rawBlob?.size ?? 0,
+ });
setContentState((prev) =>
prev.finalizingRecording ? { ...prev, finalizingRecording: false } : prev,
);
await reader.close().catch(() => {});
- // materialize so Blob URL doesn't break when mtime changes
- let blob = rawBlob;
- if (rawBlob && rawBlob.size <= 1_500_000_000) {
- try {
- const buf = await rawBlob.arrayBuffer();
- blob = new Blob([buf], { type: rawBlob.type || "video/mp4" });
- } catch {
- blob = rawBlob;
+ // Use the OPFS-backed Blob on the critical path. The previous
+ // arrayBuffer copy was defensive against mtime/deletion but
+ // could take 30-60s on slow disks for 100MB+ files (the "stuck
+ // at 90%" reports). Materialize in the background instead, so a
+ // later recording that deletes the OPFS file doesn't strand the
+ // editor.
+ const blob = rawBlob;
+ if (rawBlob) {
+ diagForward("sandbox-opfs-materialize-deferred", {
+ bytes: rawBlob.size,
+ });
+ // Fire-and-forget materialize. Swaps in once done; the video
+ // element keeps the original src so playback isn't disrupted.
+ if (rawBlob.size <= 1_500_000_000) {
+ const materializeStart = Date.now();
+ (async () => {
+ try {
+ const buf = await rawBlob.arrayBuffer();
+ const materialized = new Blob([buf], {
+ type: rawBlob.type || "video/mp4",
+ });
+ diagForward("sandbox-opfs-materialize-done", {
+ elapsedMs: Date.now() - materializeStart,
+ outputBytes: materialized.size,
+ });
+ setContentState((prev) => ({
+ ...prev,
+ blob: materialized,
+ rawBlob: prev.rawBlob || materialized,
+ }));
+ } catch (err) {
+ diagForward("sandbox-opfs-materialize-fail", {
+ elapsedMs: Date.now() - materializeStart,
+ err: String(err?.message || err).slice(0, 200),
+ });
+ }
+ })();
}
}
if (blob) {
@@ -1231,7 +1304,16 @@ const ContentState = (props) => {
null,
null,
true,
- false,
+ chrome.i18n.getMessage("getHelpButton"),
+ () => {
+ triggerSupportDownload({ source: "opfs-load-failed" });
+ chrome.runtime.sendMessage({
+ type: "report-error",
+ source: "opfs-load-failed",
+ errorCode: "OPFS_LOAD_FAILED",
+ zipBundled: true,
+ });
+ },
);
}
diagForward("sandbox-recording-load-failed", {
@@ -1375,6 +1457,7 @@ const ContentState = (props) => {
typeof contentStateRef.current?.openModal === "function"
) {
editorErrorShownRef.current = true;
+ const errCode = message?.errorCode || "OPFS_LOAD_FAILED";
contentStateRef.current.openModal(
chrome.i18n.getMessage("opfsLoadErrorTitle"),
message?.why || chrome.i18n.getMessage("opfsLoadErrorDescription"),
@@ -1386,7 +1469,16 @@ const ContentState = (props) => {
null,
null,
true,
- false,
+ 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) => ({
@@ -1760,10 +1852,12 @@ const ContentState = (props) => {
chrome.i18n.getMessage("editorStuckGetHelp"),
() => {
try {
+ triggerSupportDownload({ source: "editor-recovery-failed" });
chrome.runtime.sendMessage({
type: "report-error",
source: "editor-recovery-failed",
errorCode: payload?.errorCode || null,
+ zipBundled: true,
});
} catch {}
},
@@ -1857,6 +1951,7 @@ const ContentState = (props) => {
typeof contentStateRef.current?.openModal === "function"
) {
editorErrorShownRef.current = true;
+ const errCode = payload?.errorCode || "OPFS_LOAD_FAILED";
contentStateRef.current.openModal(
chrome.i18n.getMessage("opfsLoadErrorTitle"),
payload?.why || chrome.i18n.getMessage("opfsLoadErrorDescription"),
@@ -1868,7 +1963,16 @@ const ContentState = (props) => {
null,
null,
true,
- false,
+ 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,
diff --git a/src/pages/Sandbox/recorderStorage/opfsChunkReader.js b/src/pages/Sandbox/recorderStorage/opfsChunkReader.js
index 33a70f9..b8d58c1 100644
--- a/src/pages/Sandbox/recorderStorage/opfsChunkReader.js
+++ b/src/pages/Sandbox/recorderStorage/opfsChunkReader.js
@@ -56,12 +56,26 @@ export class OpfsChunkReader {
// !sameFile means a newer recording replaced the ref (our writer is
// gone, or we're opening an orphan file). sameFile && finalized means
- // the writer closed cleanly. otherwise wait for one of those.
+ // the writer closed cleanly. otherwise wait for one of those β€” but
+ // also watch the file size: if the writer dies without emitting the
+ // finalized marker (recorder tab killed, SW restart mid-flush, track
+ // ended mid-write), polling will time out at 60s for no reason. When
+ // size has been stable for SIZE_STABLE_MS, treat the writer as gone
+ // and read what's on disk.
if (sameFile && !finalized) {
const startedAt = Date.now();
let notified = false;
+ let timedOut = false;
+ let lastSize = -1;
+ let sizeStableSince = 0;
+ const SIZE_STABLE_MS = 3000;
+ const SIZE_STABLE_MIN_WAIT_MS = 1500;
+ let writerDead = false;
while (true) {
- if (Date.now() - startedAt > FINALIZE_HARD_TIMEOUT_MS) break;
+ if (Date.now() - startedAt > FINALIZE_HARD_TIMEOUT_MS) {
+ timedOut = true;
+ break;
+ }
if (!notified && Date.now() - startedAt > SLOW_FINALIZE_NOTIFY_MS) {
try {
onSlowFinalize?.();
@@ -71,6 +85,40 @@ export class OpfsChunkReader {
await wait(FINALIZE_POLL_INTERVAL_MS);
({ sameFile, finalized } = await this._readRefState());
if (finalized || !sameFile) break;
+ // Size-stability check. Probing the file inside the poll loop is
+ // cheap β€” getFile is metadata only on chromium.
+ try {
+ const probe = await handle.getFile();
+ if (probe.size !== lastSize) {
+ lastSize = probe.size;
+ sizeStableSince = Date.now();
+ } else if (
+ sizeStableSince > 0 &&
+ Date.now() - sizeStableSince >= SIZE_STABLE_MS &&
+ Date.now() - startedAt >= SIZE_STABLE_MIN_WAIT_MS &&
+ probe.size >= MIN_VALID_RECORDING_BYTES
+ ) {
+ writerDead = true;
+ break;
+ }
+ } catch {}
+ }
+ if (timedOut || writerDead) {
+ try {
+ chrome.runtime
+ .sendMessage({
+ type: "diag-forward",
+ event: writerDead
+ ? "sandbox-opfs-writer-dead-detected"
+ : "sandbox-opfs-wait-finalize-timeout",
+ data: {
+ fileName: this._fileName,
+ waitedMs: Date.now() - startedAt,
+ fileBytes: lastSize >= 0 ? lastSize : null,
+ },
+ })
+ .catch(() => {});
+ } catch {}
}
}
diff --git a/src/pages/utils/buildSupportContext.js b/src/pages/utils/buildSupportContext.js
index 1ca6f3f..0cef2f0 100644
--- a/src/pages/utils/buildSupportContext.js
+++ b/src/pages/utils/buildSupportContext.js
@@ -67,6 +67,13 @@ export const buildSupportContext = async (opts = {}) => {
"isSubscribed",
"diagnosticLog",
"recordingAttemptId",
+ "lastRecordingBackendRef",
+ "lastRecordingFinalizedFileName",
+ "freeRecorderSession",
+ "fastRecorderValidation",
+ "editorReadyAt",
+ "lastTrackEndEvent",
+ "editorRecordingError",
];
const store = await chrome.storage.local.get(keys);
@@ -88,6 +95,71 @@ export const buildSupportContext = async (opts = {}) => {
if (store.recordingAttemptId)
ctx.attemptId = store.recordingAttemptId;
+ // Distinguishes writer-hung from writer-ok-editor-failed for
+ // triaging stuck-at-90% reports.
+ if (store.lastRecordingBackendRef?.backend) {
+ ctx.backend = store.lastRecordingBackendRef.backend;
+ }
+ if (store.lastRecordingBackendRef?.fileName) {
+ ctx.finalized =
+ store.lastRecordingFinalizedFileName ===
+ store.lastRecordingBackendRef.fileName
+ ? "1"
+ : "0";
+ }
+
+ if (store.freeRecorderSession) {
+ if (store.freeRecorderSession.chunkCount != null)
+ ctx.chunks = String(store.freeRecorderSession.chunkCount);
+ if (store.freeRecorderSession.status)
+ ctx.recSessStatus = String(store.freeRecorderSession.status).slice(
+ 0,
+ 30,
+ );
+ }
+
+ if (store.fastRecorderValidation) {
+ ctx.validationOk = store.fastRecorderValidation.ok ? "1" : "0";
+ if (store.fastRecorderValidation.hardFail) ctx.validationHardFail = "1";
+ if (
+ !store.fastRecorderValidation.ok &&
+ Array.isArray(store.fastRecorderValidation.reasons)
+ ) {
+ ctx.validationReason = String(
+ store.fastRecorderValidation.reasons[0] || "",
+ ).slice(0, 60);
+ }
+ if (store.fastRecorderValidation.details?.size) {
+ // MB rounded; keeps the URL short.
+ ctx.fileMb = String(
+ Math.round(store.fastRecorderValidation.details.size / (1024 * 1024)),
+ );
+ }
+ }
+
+ // Editor reached ready (new instrumentation; storage mirror of
+ // contentState.ready). Absence means the editor never loaded.
+ if (store.editorReadyAt) ctx.editorReady = "1";
+
+ // Track-end reason: distinguishes graceful stop from stream-end
+ // teardown (display sleep, Chrome native Stop sharing, source-tab
+ // close). Both bug-reporters had REC_RUN_STREAM_END so this is
+ // critical for matching.
+ if (store.lastTrackEndEvent?.reason) {
+ ctx.trackEndReason = String(store.lastTrackEndEvent.reason).slice(
+ 0,
+ 60,
+ );
+ }
+
+ // Editor-side error if surfaced. Differentiates types of stuck.
+ if (store.editorRecordingError?.errorCode) {
+ ctx.editorErr = String(store.editorRecordingError.errorCode).slice(
+ 0,
+ 60,
+ );
+ }
+
if (store.diagnosticLog?.sessions?.length) {
const last =
store.diagnosticLog.sessions[
@@ -102,6 +174,20 @@ export const buildSupportContext = async (opts = {}) => {
(ev) => ev.e === "editor-load-ready",
);
if (hasEditorOpen && !hasEditorReady) ctx.editorHandoff = "incomplete";
+
+ // Last 30 events as "name@msFromSessionStart". Just the
+ // sequence, no payloads.
+ const recent = last.events.slice(-30);
+ const compact = recent
+ .map((ev) => `${ev.e}@${ev.t}`)
+ .join(",");
+ // Cap so a runaway log doesn't blow past Tally URL limits.
+ if (compact && compact.length <= 3000) {
+ ctx.diagEvents = compact;
+ } else if (compact) {
+ // Keep the most recent.
+ ctx.diagEvents = compact.slice(-3000);
+ }
}
}
} catch {}
diff --git a/src/pages/utils/diagnosticLog.js b/src/pages/utils/diagnosticLog.js
index 61ba050..16962ad 100644
--- a/src/pages/utils/diagnosticLog.js
+++ b/src/pages/utils/diagnosticLog.js
@@ -118,6 +118,26 @@ export const diagEvent = (eventType, data) => {
"drive-save-fail",
"drive-auth-fail",
"editor-load-ready",
+ // OPFS load + video element handoff: critical for diagnosing
+ // editor-stuck-at-90% reports. If any of these is the last event
+ // before a hang, that's the step that hung.
+ "sandbox-opfs-reader-open-done",
+ "sandbox-opfs-readblob-start",
+ "sandbox-opfs-readblob-done",
+ "sandbox-opfs-readblob-slow-finalize",
+ "sandbox-opfs-materialize-start",
+ "sandbox-opfs-materialize-done",
+ "sandbox-opfs-materialize-fail",
+ "sandbox-opfs-arraybuffer-done",
+ "sandbox-opfs-materialize-skipped",
+ "sandbox-video-src-set",
+ "sandbox-video-loadedmetadata",
+ "sandbox-video-load-error",
+ "sandbox-opfs-wait-finalize-timeout",
+ "sandbox-opfs-writer-dead-detected",
+ "sandbox-opfs-materialize-deferred",
+ "session-deferred-end",
+ "editor-route-decision",
];
if (ALWAYS_FLUSH.includes(eventType)) {
flush();
diff --git a/src/pages/utils/triggerSupportDownload.js b/src/pages/utils/triggerSupportDownload.js
new file mode 100644
index 0000000..4abc976
--- /dev/null
+++ b/src/pages/utils/triggerSupportDownload.js
@@ -0,0 +1,21 @@
+import { buildDiagnosticZip } from "./buildDiagnosticZip";
+
+// Anchor-tag download of the diag zip so the user can attach it to the
+// Tally form that opens right after. Fire-and-forget.
+export const triggerSupportDownload = async (opts = {}) => {
+ try {
+ const { blob, filename } = await buildDiagnosticZip(opts);
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = filename;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
+ return filename;
+ } catch (err) {
+ console.error("[Screenity] Support zip download failed:", err);
+ return null;
+ }
+};