Skip to content

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

Finish the previous upload before a new recording starts, recording into empty scenes, + clearer picker cancel and failed-upload handling

Alyssa Xdddeeb668ad2
diff --git a/package-lock.json b/package-lock.json
index 1ec5240..b479ea1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "screenity",
- "version": "4.6.11",
+ "version": "4.6.12",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "screenity",
- "version": "4.6.11",
+ "version": "4.6.12",
"hasInstallScript": true,
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.27.1",
@@ -2159,9 +2159,9 @@
}
},
"node_modules/@mediabunny/aac-encoder": {
- "version": "1.56.0",
- "resolved": "https://registry.npmjs.org/@mediabunny/aac-encoder/-/aac-encoder-1.56.0.tgz",
- "integrity": "sha512-DY69WcgiCD/cQYLq6vAE/1lVdu4asY32l9WLx7r8b+PDC5qMF9Oe+n0DoqVXNN0TOf3PT4BwAz/Yf3MtHIwCyA==",
+ "version": "1.60.0",
+ "resolved": "https://registry.npmjs.org/@mediabunny/aac-encoder/-/aac-encoder-1.60.0.tgz",
+ "integrity": "sha512-wevrs3VuwOKMmXkEn01KIwapKAe5QoGazWyND1B9pYUz+GC+wxfVcyv9kUfrpXDfy/xPhM7pOePCHSC9aw0k5A==",
"license": "MPL-2.0",
"funding": {
"type": "individual",
@@ -4849,7 +4849,6 @@
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
- "devOptional": true,
"dependencies": {
"debug": "4"
},
@@ -5033,14 +5032,15 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
- "version": "1.13.5",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.5.tgz",
- "integrity": "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q==",
+ "version": "1.20.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.20.0.tgz",
+ "integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==",
"license": "MIT",
"dependencies": {
- "follow-redirects": "^1.15.11",
- "form-data": "^4.0.5",
- "proxy-from-env": "^1.1.0"
+ "follow-redirects": "^1.16.0",
+ "form-data": "^4.0.6",
+ "https-proxy-agent": "^5.0.1",
+ "proxy-from-env": "^2.1.0"
}
},
"node_modules/babel-loader": {
@@ -7418,15 +7418,16 @@
"license": "ISC"
},
"node_modules/follow-redirects": {
- "version": "1.15.11",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
- "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
+ "version": "1.16.0",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",
+ "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
+ "license": "MIT",
"engines": {
"node": ">=4.0"
},
@@ -7437,16 +7438,16 @@
}
},
"node_modules/form-data": {
- "version": "4.0.5",
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
- "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
+ "version": "4.0.6",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz",
+ "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"es-set-tostringtag": "^2.1.0",
- "hasown": "^2.0.2",
- "mime-types": "^2.1.12"
+ "hasown": "^2.0.4",
+ "mime-types": "^2.1.35"
},
"engines": {
"node": ">= 6"
@@ -7837,9 +7838,10 @@
}
},
"node_modules/hasown": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
- "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
+ "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
+ "license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
@@ -8111,7 +8113,6 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
"integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
- "devOptional": true,
"dependencies": {
"agent-base": "6",
"debug": "4"
@@ -9006,9 +9007,9 @@
}
},
"node_modules/mediabunny": {
- "version": "1.56.0",
- "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.56.0.tgz",
- "integrity": "sha512-VLVYEVXI4fA2PabQoZs3XOmxDsio4gpG1Npz0iVICRNCQ+XYI3fBOngnwHljafaEjHUbYzrIDoctZbxcVfQpgQ==",
+ "version": "1.60.0",
+ "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.60.0.tgz",
+ "integrity": "sha512-CRQ/2D+qUF9w2IyjbjTxxSLEG+PeWeD4whb43UpUBpeNomWb/ffn+ngKgqJSPZ+bmO66MX2yBJQITZ6ijfRjug==",
"license": "MPL-2.0",
"workspaces": [
".",
@@ -10153,9 +10154,13 @@
}
},
"node_modules/proxy-from-env": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
- "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz",
+ "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ }
},
"node_modules/psl": {
"version": "1.15.0",
diff --git a/package.json b/package.json
index 833557f..f838d31 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "screenity",
- "version": "4.6.11",
+ "version": "4.6.12",
"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 fc8ac4e..6cc4cc8 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.11",
+ "version": "4.6.12",
"background": {
"service_worker": "background.bundle.js"
},
diff --git a/src/pages/Background/listeners/onActionButtonClickedListener.js b/src/pages/Background/listeners/onActionButtonClickedListener.js
index bdb8658..ebdb4dc 100644
--- a/src/pages/Background/listeners/onActionButtonClickedListener.js
+++ b/src/pages/Background/listeners/onActionButtonClickedListener.js
@@ -10,6 +10,7 @@ import { tryResumePendingUploads } from "../recording/resumePendingUploads";
import { runMicRecoveryScan } from "../../CloudRecorder/micRecovery";
import { clearInMemoryEditorLock } from "../recording/stopRecording";
import { sendMessageEnsuringContentScript } from "../utils/executeScripts";
+import { traceStep } from "../../utils/startFlowTrace";
const CLOUD_FEATURES_ENABLED =
process.env.SCREENITY_ENABLE_CLOUD_FEATURES === "true";
@@ -24,7 +25,7 @@ const handleTabMessaging = async (tab) => {
if (offscreen) {
try {
- await sendMessageRecord({ type: "stop-recording-tab" });
+ await sendMessageRecord({ type: "stop-recording-tab", reason: "action-click" });
return;
} catch (err) {
console.error(
@@ -43,15 +44,15 @@ const handleTabMessaging = async (tab) => {
: null;
if (targetTab) {
- await sendMessageTab(preferredTabId, { type: "stop-recording-tab" });
+ await sendMessageTab(preferredTabId, { type: "stop-recording-tab", reason: "action-click" });
} else {
- await sendMessageTab(tab.id, { type: "stop-recording-tab" });
+ await sendMessageTab(tab.id, { type: "stop-recording-tab", reason: "action-click" });
chrome.storage.local.set({ activeTab: tab.id });
}
} catch (error) {
console.error("[Screenity][ActionClick] handleTabMessaging failed, trying direct recorder stop:", error);
try {
- await sendMessageRecord({ type: "stop-recording-tab" });
+ await sendMessageRecord({ type: "stop-recording-tab", reason: "action-click" });
} catch (recorderErr) {
console.error("[Screenity][ActionClick] direct recorder stop also failed:", recorderErr);
}
@@ -205,6 +206,9 @@ export const onActionButtonClickedListener = () => {
if (isRecordingActive) {
const { recordingTab, offscreen } = snap;
+ if (pendingRecording && !recording) {
+ void traceStep("actionClick");
+ }
let hasActiveRecorder = false;
if (sessionRecording) {
diff --git a/src/pages/Background/listeners/onCommandListener.js b/src/pages/Background/listeners/onCommandListener.js
index 113f22a..1918bef 100644
--- a/src/pages/Background/listeners/onCommandListener.js
+++ b/src/pages/Background/listeners/onCommandListener.js
@@ -77,7 +77,7 @@ export const onCommandListener = () => {
? { type: "cancel-recording" }
: command === "pause-recording"
? { type: "pause-recording" }
- : { type: "stop-recording-tab" };
+ : { type: "stop-recording-tab", reason: "shortcut-stop" };
try {
await sendMessageTab(targetTabId, msg);
} catch (err) {
@@ -86,7 +86,10 @@ export const onCommandListener = () => {
// recording; pause/cancel need the content-script pill UI, so they
// have no direct fallback here (the user can stop via the toolbar).
if (command === "stop-recording") {
- await sendMessageRecord({ type: "stop-recording-tab" }).catch(
+ await sendMessageRecord({
+ type: "stop-recording-tab",
+ reason: "shortcut-stop",
+ }).catch(
() => {},
);
}
diff --git a/src/pages/Background/recording/openRecorderTab.js b/src/pages/Background/recording/openRecorderTab.js
index ac2cbc3..67844f8 100644
--- a/src/pages/Background/recording/openRecorderTab.js
+++ b/src/pages/Background/recording/openRecorderTab.js
@@ -1,4 +1,4 @@
-import { getCurrentTab } from "../tabManagement";
+import { getCurrentTab, sendMessageTab } from "../tabManagement";
import { removeTab } from "../tabManagement/removeTab";
import { sendMessageRecord } from "./sendMessageRecord.js";
import { closeOffscreenDocumentWithFlush } from "../offscreen/closeOffscreenDocumentWithFlush";
@@ -9,6 +9,10 @@ import { handleGetStreamingData } from "./recordingHelpers.js";
import { perfMark, perfSpan } from "../../utils/perfMarks";
import { sweepRecorderTabs } from "./sweepRecorderTabs";
import { applyRetentionPlan } from "./recordingRetention";
+import {
+ holdForPreviousRecorder,
+ readPreviousRecorderState,
+} from "./previousRecorderGate";
const openRecorderTab = async (
activeTab,
@@ -359,6 +363,47 @@ export const startRecorderSession = async (request, tabId = null) => {
chrome.storage.local.set({ tabPreferred: false });
}
+ // Closing the offscreen doc below cuts off a take that is still finalizing,
+ // so hold for it and refuse this start rather than close it.
+ if (!request.customRegion) {
+ try {
+ const { useOffscreenCloud } = await chrome.storage.local.get([
+ "useOffscreenCloud",
+ ]);
+ if (useOffscreenCloud !== false) {
+ const toast = (message, timeout) =>
+ sendMessageTab(activeTab.id, {
+ type: "show-toast",
+ message,
+ timeout,
+ }).catch(() => {});
+ const gate = await holdForPreviousRecorder({
+ read: readPreviousRecorderState,
+ onHold: () =>
+ toast("Finishing your previous recording before starting.", 8000),
+ });
+ if (gate.refused) {
+ toast(
+ "Your previous recording is still uploading. Wait for it to finish, then start again.",
+ 10000,
+ );
+ await chrome.storage.local.set({
+ lastStartAborted: {
+ ts: Date.now(),
+ waitedMs: gate.waitedMs,
+ reason: "previous-recording-finalizing",
+ },
+ recordingStartingAt: null,
+ pendingRecording: false,
+ });
+ return;
+ }
+ }
+ } catch (err) {
+ console.warn("[Screenity][BG] previous recorder gate failed", err);
+ }
+ }
+
const endCloseOffscreen = perfSpan("BG.startRecorderSession closeOffscreenDocument");
// finalize any in-flight offscreen upload before teardown; a back-to-back
// start otherwise bare-closes the prior TUS finalize and loses it
diff --git a/src/pages/Background/recording/previousRecorderGate.js b/src/pages/Background/recording/previousRecorderGate.js
new file mode 100644
index 0000000..6893060
--- /dev/null
+++ b/src/pages/Background/recording/previousRecorderGate.js
@@ -0,0 +1,64 @@
+// Chrome allows one offscreen document, so a new take closes the old one,
+// cutting off uploads and the scene POST if it is still finalizing. Wait, and
+// refuse the new start rather than close it.
+export const HOLD_TIMEOUT_MS = 60000;
+export const HOLD_POLL_MS = 500;
+// Past this the session isn't being written any more: a leftover "stopping"
+// is a wedged recorder, not an upload.
+export const STALE_SESSION_MS = 5 * 60 * 1000;
+const FINALIZING_STATUSES = new Set(["stopping", "finishing"]);
+
+export const isPreviousRecorderFinalizing = ({
+ hasOffscreenRecorder,
+ session,
+ now = Date.now(),
+}) => {
+ if (!hasOffscreenRecorder || !session) return false;
+ if (!FINALIZING_STATUSES.has(session.status)) return false;
+ const at = Number(session.updatedAt);
+ if (Number.isFinite(at) && at > 0 && now - at > STALE_SESSION_MS) {
+ return false;
+ }
+ return true;
+};
+
+// Resolves { held, waitedMs, refused }. `onHold` fires once when the wait
+// begins, so the caller can tell the user why.
+export const holdForPreviousRecorder = async ({
+ read,
+ onHold = () => {},
+ timeoutMs = HOLD_TIMEOUT_MS,
+ pollMs = HOLD_POLL_MS,
+ sleep = (ms) => new Promise((r) => setTimeout(r, ms)),
+ now = Date.now,
+}) => {
+ const startedAt = now();
+ if (!isPreviousRecorderFinalizing({ ...(await read()), now: now() })) {
+ return { held: false, waitedMs: 0, refused: false };
+ }
+ onHold();
+ while (now() - startedAt < timeoutMs) {
+ await sleep(pollMs);
+ if (!isPreviousRecorderFinalizing({ ...(await read()), now: now() })) {
+ return { held: true, waitedMs: now() - startedAt, refused: false };
+ }
+ }
+ return { held: true, waitedMs: now() - startedAt, refused: true };
+};
+
+export const readPreviousRecorderState = async () => {
+ let hasOffscreenRecorder = false;
+ try {
+ const contexts = await chrome.runtime.getContexts({});
+ hasOffscreenRecorder = (contexts || []).some(
+ (c) =>
+ c.contextType === "OFFSCREEN_DOCUMENT" &&
+ typeof c.documentUrl === "string" &&
+ c.documentUrl.includes("offscreenrecorder.html")
+ );
+ } catch {}
+ const { recorderSession } = await chrome.storage.local.get([
+ "recorderSession",
+ ]);
+ return { hasOffscreenRecorder, session: recorderSession || null };
+};
diff --git a/src/pages/CloudRecorder/CloudRecorder.jsx b/src/pages/CloudRecorder/CloudRecorder.jsx
index b80165b..039dd28 100644
--- a/src/pages/CloudRecorder/CloudRecorder.jsx
+++ b/src/pages/CloudRecorder/CloudRecorder.jsx
@@ -88,6 +88,7 @@ import {
} from "./audioBusPolicy";
import {
setPendingMicRecovery,
+ setPendingMicRecoveryScene,
clearPendingMicRecovery,
runMicRecoveryScan,
} from "./micRecovery";
@@ -3372,7 +3373,7 @@ const CloudRecorder = () => {
createBlobFromChunks(cameraChunks.current, "video/webm");
fromMemoryWindow = Boolean(blob);
}
- if (!blob) return;
+ if (!blob) return false;
// Purge drops Bunny-confirmed chunks mid-recording and the memory window
// holds only the last 8, so either source can be missing the middle.
const partial =
@@ -3403,11 +3404,13 @@ const CloudRecorder = () => {
purgedScreenChunks: screenChunksPurgedCountRef.current,
purgedBytes: chunksPurgedBytesRef.current,
});
+ return true;
} finally {
URL.revokeObjectURL(objectUrl);
}
} catch (err) {
console.warn("Failed to export local recovery:", err);
+ return false;
}
};
@@ -3875,6 +3878,9 @@ const CloudRecorder = () => {
typeof why === "string" ? why : JSON.stringify(why)
} cancel=${cancel}`
);
+ // A failed take never hits markSceneComplete, so getOrCreateSceneId would
+ // hand its "recording" id to the next take (the BG clear skips the editor).
+ chrome.storage.local.set({ sceneIdStatus: "failed" }).catch(() => {});
void cleanupIfEmptyUploads("error");
sendRecordingErrorBase(why, cancel);
};
@@ -5912,14 +5918,18 @@ const CloudRecorder = () => {
};
};
- const handleTranscription = async (uploadMeta, projectId) => {
+ const handleTranscription = async (
+ uploadMeta,
+ projectId,
+ sceneId = uploadMeta.sceneId
+ ) => {
if (!uploadMeta.audio || !uploadMeta.audio.mediaId) return;
try {
const transcriptionTarget =
uploadMeta.screen?.mediaId || uploadMeta.camera?.mediaId;
if (transcriptionTarget) {
- const dedupeKey = `transcriptionQueued:${uploadMeta.sceneId}:${uploadMeta.audio.mediaId}`;
+ const dedupeKey = `transcriptionQueued:${sceneId}:${uploadMeta.audio.mediaId}`;
const dedupe = await chrome.storage.local.get([dedupeKey]);
if (dedupe?.[dedupeKey]) return;
@@ -5938,7 +5948,7 @@ const CloudRecorder = () => {
body: JSON.stringify({
output: `transcriptions/${uploadMeta.audio.mediaId}.json`,
videoId: projectId,
- sceneId: uploadMeta.sceneId,
+ sceneId,
inputMediaId: uploadMeta.audio.mediaId,
targetMediaId: transcriptionTarget,
lang: "en",
@@ -5948,7 +5958,7 @@ const CloudRecorder = () => {
await chrome.storage.local.set({ [dedupeKey]: true });
logDebugEvent("transcription-queued", {
projectId,
- sceneId: uploadMeta.sceneId,
+ sceneId,
inputMediaId: uploadMeta.audio.mediaId,
targetMediaId: transcriptionTarget,
});
@@ -5957,7 +5967,7 @@ const CloudRecorder = () => {
console.warn("❌ Transcription failed:", err);
logDebugEvent("transcription-failed", {
projectId,
- sceneId: uploadMeta.sceneId,
+ sceneId,
error: err?.message || String(err),
});
}
@@ -6421,6 +6431,9 @@ const CloudRecorder = () => {
const existingStatus = await getSceneCreateStatus(sceneId);
let sceneOutcome = null;
let shouldIncrementMultiSceneCount = false;
+ // The server files a take into an empty target scene under that scene's
+ // id and returns it. Everything after the POST must use this id.
+ let effectiveSceneId = sceneId;
if (existingStatus?.status === "created") {
logDebugEvent("scene-create-skip", {
@@ -6648,6 +6661,24 @@ const CloudRecorder = () => {
// parallel below since nothing in the handoff reads it.
sceneOutcome = "created";
shouldIncrementMultiSceneCount = true;
+ const replySceneId = swRes?.body?.sceneId;
+ if (typeof replySceneId === "string" && replySceneId) {
+ effectiveSceneId = replySceneId;
+ }
+ // The BG matches the offer on the scene the editor opens, so it has to
+ // follow the remap.
+ const offerToRekey = localScreenPlaybackOfferRef.current;
+ if (offerToRekey && offerToRekey.sceneId !== effectiveSceneId) {
+ try {
+ const rekeyed = await chrome.runtime.sendMessage({
+ type: "cloud-local-playback-register",
+ offer: { ...offerToRekey, sceneId: effectiveSceneId },
+ });
+ if (rekeyed?.ok && rekeyed.offer) {
+ localScreenPlaybackOfferRef.current = rekeyed.offer;
+ }
+ } catch {}
+ }
if (multiMode && shouldIncrementMultiSceneCount) {
// Multi needs count + lastSceneId persisted before
@@ -6655,7 +6686,7 @@ const CloudRecorder = () => {
// reads them. Keep this awaited path for multi.
await chrome.storage.local.set({
multiSceneCount: multiSceneCount + 1,
- multiLastSceneId: sceneId,
+ multiLastSceneId: effectiveSceneId,
});
chrome.runtime.sendMessage({
type: "reopen-popup-multi",
@@ -6664,7 +6695,7 @@ const CloudRecorder = () => {
sendEditorReady({
projectId,
- sceneId,
+ sceneId: effectiveSceneId,
recordingToScene,
multiMode,
});
@@ -6687,6 +6718,7 @@ const CloudRecorder = () => {
return {
created: true,
micIncluded: Boolean(separatedMic?.mediaId),
+ sceneId: effectiveSceneId,
};
}
}
@@ -6694,7 +6726,7 @@ const CloudRecorder = () => {
if (multiMode && shouldIncrementMultiSceneCount) {
await chrome.storage.local.set({
multiSceneCount: multiSceneCount + 1,
- multiLastSceneId: sceneId,
+ multiLastSceneId: effectiveSceneId,
});
chrome.runtime.sendMessage({
type: "reopen-popup-multi",
@@ -6703,13 +6735,13 @@ const CloudRecorder = () => {
sendEditorReady({
projectId,
- sceneId,
+ sceneId: effectiveSceneId,
recordingToScene,
multiMode,
});
await chrome.storage.local.remove("clickEvents");
- return { [sceneOutcome || "created"]: true };
+ return { [sceneOutcome || "created"]: true, sceneId: effectiveSceneId };
};
const isAudioSilent = async (audioBlob, silenceThreshold = 0.01) => {
@@ -6759,6 +6791,11 @@ const CloudRecorder = () => {
};
stopFlowRef.current.tick = stopTick;
stopTick("stop-pressed", { reason, shouldFinalize });
+ if (!screenStream.current && !cameraStream.current) {
+ void traceStep("stopRequested", {
+ stopReason: String(reason).slice(0, 40),
+ });
+ }
if (DEBUG_START_FLOW) {
console.debug("[Screenity] stopRecording invoked", {
@@ -7070,7 +7107,12 @@ const CloudRecorder = () => {
emitRecordingOutcome("unrecoverable", {
reason: "uploader-finalize-incomplete",
});
- await exportLocalRecovery("finalize-error");
+ // Nothing uploaded: drop the empty project and stub media, as for any
+ // other take that never uploaded.
+ if ((screenMeta?.offset || 0) === 0 && (cameraMeta?.offset || 0) === 0) {
+ await cleanupIfEmptyUploads("finalize-empty");
+ }
+ const recoverySaved = await exportLocalRecovery("finalize-error");
await chunksStore
.clear()
.catch((e) =>
@@ -7084,7 +7126,9 @@ const CloudRecorder = () => {
await clearCameraChunkStore("finalize-error");
await clearLocalScreenPlaybackOffer("finalize-error");
sendRecordingError(
- "Upload failed to finalize. A recovery copy was downloaded."
+ recoverySaved
+ ? "Upload failed to finalize. A recovery copy was downloaded."
+ : "Upload failed to finalize."
);
return;
}
@@ -7159,11 +7203,26 @@ const CloudRecorder = () => {
e
)
);
- emitRecordingOutcome("abandoned", { reason: "no-upload" });
+ // No session and no stream: capture never began (picker dismissed or
+ // unanswered), so this is a cancel, not a failed upload.
+ const captureNeverStarted =
+ !recorderSession.current &&
+ !screenStream.current &&
+ !cameraStream.current;
+ emitRecordingOutcome("abandoned", {
+ reason: captureNeverStarted ? "no-stream" : "no-upload",
+ });
await finalizeRecorderSession("failed");
await clearAudioChunkStore("no-upload");
await clearCameraChunkStore("no-upload");
await clearLocalScreenPlaybackOffer("no-upload");
+ if (captureNeverStarted) {
+ sendRecordingError(
+ "Recording cancelled: no capture stream was acquired.",
+ true
+ );
+ return;
+ }
sendRecordingError(
`No media was successfully uploaded. Screen: ${screenStatus} (${screenOffset} bytes, error: ${screenError}), Camera: ${cameraStatus} (${cameraOffset} bytes, error: ${cameraError})`
);
@@ -7286,16 +7345,6 @@ const CloudRecorder = () => {
if (!sentLast.current) {
sentLast.current = true;
try {
- // Fire-and-forget transcription queue: not awaited so it doesn't
- // extend the cloudrecorder's post-stop tail. The fetch dispatches
- // synchronously into Chrome's network stack, so the request leaves
- // the page even if window.close fires shortly after.
- if (!silent && uploadMeta.audio?.mediaId) {
- handleTranscription(uploadMeta, projectId).catch((err) =>
- console.warn("[CloudRecorder] handleTranscription failed:", err)
- );
- }
-
diagForward("mic-upload-decision", {
willUploadMic,
// Both, on purpose: a take where they disagree is the 4.6.9 bug,
@@ -7342,6 +7391,24 @@ const CloudRecorder = () => {
silent,
separatedMic
);
+ // The mic upload and marker use the minted id; the attach must name
+ // the scene the server actually filed the take under.
+ const micSceneId = sceneResult?.sceneId || uploadMeta.sceneId;
+ // Not awaited so it doesn't extend the post-stop tail. The fetch
+ // dispatches synchronously, so it leaves the page even if window.close
+ // fires shortly after. Runs after the POST to use the effective scene id.
+ if (!silent && uploadMeta.audio?.mediaId) {
+ handleTranscription(uploadMeta, projectId, micSceneId).catch((err) =>
+ console.warn("[CloudRecorder] handleTranscription failed:", err)
+ );
+ }
+ if (willUploadMic && micSceneId !== uploadMeta.sceneId) {
+ await setPendingMicRecoveryScene(uploadMeta.sceneId, micSceneId);
+ diagForward("separated-mic-scene-remapped", {
+ from: String(uploadMeta.sceneId).slice(0, 40),
+ to: String(micSceneId).slice(0, 40),
+ });
+ }
if (!willUploadMic) {
await chrome.storage.local
@@ -7372,7 +7439,7 @@ const CloudRecorder = () => {
mediaId: separatedMic.mediaId,
separated: true,
};
- handleTranscription(uploadMeta, projectId).catch((err) =>
+ handleTranscription(uploadMeta, projectId, micSceneId).catch((err) =>
console.warn(
"[CloudRecorder] separated handleTranscription failed:",
err
@@ -7407,7 +7474,7 @@ const CloudRecorder = () => {
: await (async () => {
const attached = await attachSceneAudio({
projectId,
- sceneId: uploadMeta.sceneId,
+ sceneId: micSceneId,
audioMediaId: uploaded.mediaId,
duration: usedDurations.audio || null,
token: screenityToken,
@@ -7417,6 +7484,7 @@ const CloudRecorder = () => {
ok: true,
mediaId: uploaded.mediaId,
attached: attached.attached,
+ reason: attached.reason,
}
: {
ok: false,
@@ -7430,6 +7498,7 @@ const CloudRecorder = () => {
diagForward("separated-mic-attached", {
mediaId: String(result.mediaId).slice(0, 40),
attached: result.attached,
+ reason: result.reason || null,
});
// The scene POST had no transcription source: the mic media did
// not exist yet, and this path builds no TUS uploader to fill
@@ -7440,11 +7509,12 @@ const CloudRecorder = () => {
mediaId: result.mediaId,
separated: true,
};
- handleTranscription(uploadMeta, projectId).catch((err) =>
- console.warn(
- "[CloudRecorder] separated handleTranscription failed:",
- err
- )
+ handleTranscription(uploadMeta, projectId, micSceneId).catch(
+ (err) =>
+ console.warn(
+ "[CloudRecorder] separated handleTranscription failed:",
+ err
+ )
);
}
} else {
@@ -7782,6 +7852,7 @@ const CloudRecorder = () => {
},
audio: data.systemAudio,
};
+ void traceStep("pickerRequested");
const stream = await acquireDisplayMediaWithFocusRetry({
getDisplayMedia: (c) => navigator.mediaDevices.getDisplayMedia(c),
constraints,
@@ -8044,6 +8115,7 @@ const CloudRecorder = () => {
onReactivate: () =>
chrome.runtime.sendMessage({ type: "activate-recorder-tab" }),
});
+ void traceStep("pickerRequested");
try {
screenStream.current = await acquireDisplay(displayConstraints);
} catch (err) {
@@ -8820,7 +8892,12 @@ const CloudRecorder = () => {
// (canBeginRecording).
const endUploaderInit = perfSpan("CloudRecorder initializeUploaders");
const uploaderInitStartedAt = Date.now();
- uploadersInitialized.current = await initializeUploaders();
+ // A take that died before a session registered leaves this set, and the
+ // next take on this instance would reuse its id.
+ if (!recorderSession.current) recordingSessionId.current = null;
+ uploadersInitialized.current = await initializeUploaders({
+ forceNewSceneId: true,
+ });
const uploaderInitMs = Date.now() - uploaderInitStartedAt;
endUploaderInit({ ok: Boolean(uploadersInitialized.current) });
if (!uploadersInitialized.current) {
@@ -8987,6 +9064,7 @@ const CloudRecorder = () => {
chrome.storage.local.set({ lastScreenCaptureApi: "desktopCapture" });
// Desktop picker path: non-tab mode without region, or tabPreferred forced
// isTab=false (playground) so there's no pre-obtained streamId.
+ void traceStep("pickerRequested");
chrome.desktopCapture.chooseDesktopMedia(
["screen", "window", "tab", "audio"],
null,
diff --git a/src/pages/CloudRecorder/micRecovery.js b/src/pages/CloudRecorder/micRecovery.js
index 0074c4a..5c836e1 100644
--- a/src/pages/CloudRecorder/micRecovery.js
+++ b/src/pages/CloudRecorder/micRecovery.js
@@ -64,6 +64,18 @@ export const setPendingMicRecovery = async (info) => {
} catch {}
};
+// The marker stays keyed on the minted id (the in-flight guard and the stop
+// path's clear use it); the scene's real id rides along as effectiveSceneId.
+export const setPendingMicRecoveryScene = async (sceneId, effectiveSceneId) => {
+ if (!sceneId || !effectiveSceneId) return;
+ try {
+ const map = await readMarkerMap();
+ if (!map[sceneId]) return;
+ map[sceneId] = { ...map[sceneId], effectiveSceneId };
+ await chrome.storage.local.set({ [MARKER_KEY]: map });
+ } catch {}
+};
+
export const clearPendingMicRecovery = async (sceneId = null) => {
try {
if (!sceneId) {
@@ -209,6 +221,7 @@ const _attempted = new Set();
const recoverOne = async (marker, { logger, token, ignoreLiveRecording }) => {
const key = `${marker.sceneId}:${marker.at}`;
+ const targetSceneId = marker.effectiveSceneId || marker.sceneId;
if (_attempted.has(key)) return { ran: false, reason: "already-ran" };
if (Date.now() - (marker.at || 0) > MAX_MARKER_AGE_MS) {
@@ -243,7 +256,10 @@ const recoverOne = async (marker, { logger, token, ignoreLiveRecording }) => {
// Crash recovery writes this marker before the scene exists, and attaching to
// a missing scene reads as settled and clears the voice.
if (marker.awaitScene) {
- const scene = await fetchScene(marker, token);
+ const scene = await fetchScene(
+ { projectId: marker.projectId, sceneId: targetSceneId },
+ token
+ );
if (!scene) return { ran: false, reason: "scene-not-ready" };
// The stop path attached it and was only cut off before cleaning up.
// Sending it again would orphan a second copy on Storage.
@@ -264,7 +280,7 @@ const recoverOne = async (marker, { logger, token, ignoreLiveRecording }) => {
const result = await uploadAndAttachMic({
store,
projectId: marker.projectId,
- sceneId: marker.sceneId,
+ sceneId: targetSceneId,
duration: marker.duration,
mimeType: marker.mimeType || "audio/webm",
token,
@@ -274,7 +290,7 @@ const recoverOne = async (marker, { logger, token, ignoreLiveRecording }) => {
await clearPendingMicRecovery(marker.sceneId);
await queueTranscription({
projectId: marker.projectId,
- sceneId: marker.sceneId,
+ sceneId: targetSceneId,
audioMediaId: result.mediaId,
targetMediaId: marker.targetMediaId,
token,
diff --git a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
index 6126af1..18b34cb 100644
--- a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
+++ b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
@@ -356,6 +356,10 @@ export class WebCodecsRecorder {
this._chunksOut = 0;
this._framesFromMSTP = 0;
this._staticFrameSyntheticCount = 0;
+ // Ahead-of-clock drops are real source frames; gap skips are timeline
+ // slots, not frames. Tells a quiet source from a loop discarding frames.
+ this._framesDroppedAheadOfClock = 0;
+ this._framesSkippedForGap = 0;
// Black placeholder frames synthesized before the first real frame to
// bridge macOS static-screen first-frame starvation (see readVideoLoop).
this._syntheticFirstFrameCount = 0;
@@ -489,6 +493,8 @@ export class WebCodecsRecorder {
// iteration and records nothing.
this._pendingVideoRead = null;
this._pendingAudioRead = null;
+ this._framesDroppedAheadOfClock = 0;
+ this._framesSkippedForGap = 0;
this._droppedForBackpressureCount = 0;
this._droppedAudioForBackpressureCount = 0;
this._peakVideoEncodeQueueSize = 0;
@@ -1319,6 +1325,23 @@ export class WebCodecsRecorder {
};
}
+ // Chrome's frame counts for this track. Missing in some builds, so absent
+ // reads as null, not zero.
+ _readTrackStats() {
+ try {
+ const st = this.videoTrack?.stats;
+ if (!st) return null;
+ const num = (v) => (Number.isFinite(v) ? v : null);
+ return {
+ totalFrames: num(st.totalFrames),
+ deliveredFrames: num(st.deliveredFrames),
+ discardedFrames: num(st.discardedFrames),
+ };
+ } catch {
+ return null;
+ }
+ }
+
getDiagSnapshot() {
let firstChunkLatencyMs = null;
if (this._firstChunkAt != null && this._videoStartUs != null) {
@@ -1344,6 +1367,9 @@ export class WebCodecsRecorder {
chunksOut: this._chunksOut,
framesFromMSTP: this._framesFromMSTP,
staticFrameSyntheticCount: this._staticFrameSyntheticCount,
+ framesDroppedAheadOfClock: this._framesDroppedAheadOfClock,
+ framesSkippedForGap: this._framesSkippedForGap,
+ trackStats: this._readTrackStats(),
firstChunkLatencyMs,
videoEncoderStateAtStop: this._videoEncoderStateAtStop,
encoderConstructCount: this._encoderConstructCount,
@@ -3044,6 +3070,7 @@ export class WebCodecsRecorder {
// Drop frames ahead of wall-clock.
if (targetIndex < this._videoFrameIndex) {
+ if (frame) this._framesDroppedAheadOfClock += 1;
frame?.close();
continue;
}
@@ -3056,6 +3083,7 @@ export class WebCodecsRecorder {
const gap = targetIndex - this._videoFrameIndex;
if (gap > MAX_GAP_FRAMES) {
this.warn(`[WCR] skipping ${gap - MAX_GAP_FRAMES} frames (tab gap)`);
+ this._framesSkippedForGap += gap - MAX_GAP_FRAMES;
this._videoFrameIndex = targetIndex - MAX_GAP_FRAMES;
}
diff --git a/src/pages/utils/startFlowTrace.js b/src/pages/utils/startFlowTrace.js
index 74fbaa4..6931026 100644
--- a/src/pages/utils/startFlowTrace.js
+++ b/src/pages/utils/startFlowTrace.js
@@ -31,6 +31,10 @@ export const initStartFlowTrace = async (attemptId, config = {}) => {
startStreaming: null,
desktopCaptureSent: null,
recorderTabCreated: null,
+ recorderOffscreenCreated: null,
+ pickerRequested: null,
+ actionClick: null,
+ stopRequested: null,
streamAcquired: null,
preparingSent: null,
preparingReceived: null,
@@ -205,6 +209,10 @@ export const formatStartFlowTimeline = (trace) => {
"startStreaming",
"desktopCaptureSent",
"recorderTabCreated",
+ "recorderOffscreenCreated",
+ "pickerRequested",
+ "actionClick",
+ "stopRequested",
"streamAcquired",
"preparingSent",
"preparingReceived",