The free and privacy-friendly screen recorder with no limits 🎥
JavaScript annotationannotation-toolaudiocamerachrome-extensiondesigneditorffmpegjavascriptproductivityrecorderscreen-capturescreen-recorderscreencasttensorflowvideo
WebCodecs telemetry to diagnose empty recordings, plus fix encoderHwSlots wiring
Alyssa X4836e63ef4df
diff --git a/package.json b/package.jsonindex d8d66fa..7c8cc54 100755--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "screenity",- "version": "4.4.11",+ "version": "4.4.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.jsonindex 18cb6da..06e73e5 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.11",+ "version": "4.4.12","background": {"service_worker": "background.bundle.js"},diff --git a/src/pages/Background/recording/emitRecordingTelemetry.js b/src/pages/Background/recording/emitRecordingTelemetry.jsindex 59ed238..b1050b8 100644--- a/src/pages/Background/recording/emitRecordingTelemetry.js+++ b/src/pages/Background/recording/emitRecordingTelemetry.js@@ -51,16 +51,23 @@ export const emitRecordingTelemetry = async (eventType, extra = {}) => {const screenUploader = session?.tracks?.screen?.uploader || null;const cameraUploader = session?.tracks?.camera?.uploader || null;+ // The early beacon fires before this attempt has a session doc, so a+ // recorderSession in storage is the prior recording's. Skip the fallback+ // so we don't tag the beacon with a stale mediaId.+ const isEarlyBeacon = eventType === "recording_initiated_beacon";const mediaId =extra.mediaId ||- screenUploader?.mediaId ||- cameraUploader?.mediaId ||- null;+ (isEarlyBeacon+ ? null+ : screenUploader?.mediaId || cameraUploader?.mediaId || null);const extVersion = chrome?.runtime?.getManifest?.()?.version || null;+ const requestRecordingId =+ extra.recordingId || mediaId || recordingSessionId || null;+const body = JSON.stringify({- recordingId: mediaId,+ recordingId: requestRecordingId,recordingSessionId,projectId: extra.projectId || session?.projectId || null,sceneId: extra.sceneId || session?.sceneId || null,@@ -100,7 +107,8 @@ export const emitRecordingTelemetry = async (eventType, extra = {}) => {keepalive: true,body,});- if (res.status === 404 || res.status === 405) {+ if (res.status === 404 || res.status === 405 || res.status === 413) {+ // 413 means the payload is too big; stop sending until a redeploy.disabled = true;}} catch {diff --git a/src/pages/Background/recording/startRecording.js b/src/pages/Background/recording/startRecording.jsindex d047fd0..c5e348c 100644--- a/src/pages/Background/recording/startRecording.js+++ b/src/pages/Background/recording/startRecording.js@@ -5,6 +5,7 @@ import { initDiagSession, diagEvent } from "../../utils/diagnosticLog";import { makeRecordingAttemptId } from "../../utils/errorCodes";import { lifecycle } from "../../utils/lifecycleLog";import { sweepRecorderTabs } from "./sweepRecorderTabs";+import { emitRecordingTelemetry } from "./emitRecordingTelemetry";// `recording` flag isn't set until the recorder iframe inits (seconds later),// so countdown-finished + 8s fallback can both fire and open two recorder tabs@@ -344,6 +345,53 @@ const _startRecordingInner = async (caller) => {// sync log so the event flushes to storage before SW can be killeddiagEvent("session-start", { region: Boolean(customRegion), caller });+ // Fire-and-forget beacon before the recorder tab exists, so sessions+ // that die early still leave a server-side breadcrumb. Skipped for+ // anonymous users to avoid 401 spam.+ void (async () => {+ try {+ const tokenSnap = await chrome.storage.local.get(["screenityToken"]);+ if (!tokenSnap?.screenityToken) return;+ const [extras, tabs, wins] = await Promise.all([+ chrome.storage.local.get([+ "screenityUser",+ "fpsValue",+ "cameraActive",+ "micActive",+ "recordedTabDomain",+ ]),+ chrome.tabs.query({}).catch(() => []),+ chrome.windows.getAll({}).catch(() => []),+ ]);+ const userObj = extras?.screenityUser || null;+ await emitRecordingTelemetry("recording_initiated_beacon", {+ recordingSessionId: recordingAttemptId,+ userIdHint: userObj?._id || userObj?.id || null,+ userAgentFull:+ typeof navigator !== "undefined" && navigator.userAgent+ ? String(navigator.userAgent).slice(0, 256)+ : null,+ platformFull:+ typeof navigator !== "undefined" && navigator.platform+ ? String(navigator.platform).slice(0, 64)+ : null,+ hardwareConcurrency: Number.isFinite(navigator?.hardwareConcurrency)+ ? navigator.hardwareConcurrency+ : null,+ recordingType: recordingType || "screen",+ qualityValue: quality || null,+ fpsValue: extras?.fpsValue || null,+ cameraActive: Boolean(extras?.cameraActive),+ micActive: Boolean(extras?.micActive),+ systemAudio: Boolean(systemAudio),+ multiMode: Boolean(multiMode),+ tabsCount: Array.isArray(tabs) ? tabs.length : null,+ windowsCount: Array.isArray(wins) ? wins.length : null,+ recordedTabDomain: extras?.recordedTabDomain || null,+ });+ } catch {}+ })();+const { recordingTab: prevRecTab } = await chrome.storage.local.get(["recordingTab",]);diff --git a/src/pages/CloudRecorder/CloudRecorder.jsx b/src/pages/CloudRecorder/CloudRecorder.jsxindex 5791d1a..f6c62a9 100644--- a/src/pages/CloudRecorder/CloudRecorder.jsx+++ b/src/pages/CloudRecorder/CloudRecorder.jsx@@ -34,6 +34,7 @@ import {resetEncoderProbeCache,computeEncodedDimensions,} from "./encoder/chooseEncoder";+import { getCompressedLifecycleLog } from "../utils/lifecycleLog";localforage.config({driver: localforage.INDEXEDDB,@@ -102,6 +103,35 @@ let trackContainers = {let trackCodecs = { screen: "vp9", audio: "opus", camera: "vp9" };let encoderHwSlots = null;+// Diagnostic-only snapshot taken once at session start. userAgent is+// fingerprinting-grade but is already covered by the crash-reports+// clause in the privacy policy; the rest are aggregate.+const captureSessionDiag = () => {+ try {+ const nav = navigator || {};+ return {+ userAgentFull:+ typeof nav.userAgent === "string"+ ? nav.userAgent.slice(0, 256)+ : null,+ platformFull:+ typeof nav.platform === "string" ? nav.platform.slice(0, 64) : null,+ hardwareConcurrency: Number.isFinite(nav.hardwareConcurrency)+ ? nav.hardwareConcurrency+ : null,+ deviceMemoryGb: Number.isFinite(nav.deviceMemory)+ ? nav.deviceMemory+ : null,+ pageVisibilityStateAtStart:+ typeof document !== "undefined" && document.visibilityState+ ? document.visibilityState+ : null,+ };+ } catch {+ return null;+ }+};+const urlParams = new URLSearchParams(window.location.search);const IS_INJECTED_IFRAME = urlParams.has("injected");const IS_IFRAME_CONTEXT =@@ -559,7 +589,18 @@ const CloudRecorder = () => {screenUploader.current?.getMeta?.()?.mediaId ||cameraUploader.current?.getMeta?.()?.mediaId ||null;- if (!mediaId && eventPayload.event !== "recording_outcome") {+ // Diagnostic events fire before mediaId exists; keep them and let the+ // server attach them by recordingSessionId instead.+ const DIAG_EVENT_TYPES = new Set([+ "recording_heartbeat",+ "recording_stop_diag",+ "recording_failed_bundle",+ ]);+ if (+ !mediaId &&+ eventPayload.event !== "recording_outcome" &&+ !DIAG_EVENT_TYPES.has(eventPayload.event)+ ) {return null;}@@ -569,8 +610,10 @@ const CloudRecorder = () => {? parseInt(browserVersion, 10): null;+ const recordingIdForRequest =+ mediaId || eventPayload.recordingSessionId || null;return {- recordingId: mediaId,+ recordingId: recordingIdForRequest,recordingSessionId: eventPayload.recordingSessionId || null,projectId: eventPayload.projectId || null,sceneId: eventPayload.sceneId || null,@@ -611,8 +654,15 @@ const CloudRecorder = () => {recordingSessionId: eventPayload.recordingSessionId || null,codec: eventPayload.codec || null,container: eventPayload.container || null,- encoderKind: eventPayload.encoderKind || null,- encoderHwSlots: eventPayload.encoderHwSlots || null,+ // Fall back to the module globals so post-startup events carry+ // these without every caller threading them through. Events before+ // encoder selection still get null, which is correct.+ encoderKind:+ eventPayload.encoderKind ||+ encoderKinds.screen ||+ encoderKinds.camera ||+ null,+ encoderHwSlots: eventPayload.encoderHwSlots || encoderHwSlots || null,storageBackend: eventPayload.storageBackend || null,storageInitMs:typeof eventPayload.storageInitMs === "number"@@ -664,7 +714,7 @@ const CloudRecorder = () => {keepalive: true,body,});- if (res.status === 404 || res.status === 405) {+ if (res.status === 404 || res.status === 405 || res.status === 413) {uploadTelemetryNetworkDisabledRef.current = true;}} catch {}@@ -1686,6 +1736,7 @@ const CloudRecorder = () => {trackContainers: { ...trackContainers },trackCodecs: { ...trackCodecs },encoderHwSlots,+ diag: captureSessionDiag(),...meta,};recorderSession.current = session;@@ -1740,6 +1791,35 @@ const CloudRecorder = () => {) => {if (!recorderSession.current) return;const sessionId = recorderSession.current.id;+ // Final snapshot before the recorders get cleared, emitted even on+ // cancel/failed so a recording that never finalizes is still+ // observable. The lifecycle bundle attaches only on suspected+ // failures to keep healthy payloads small.+ try {+ const screenDiag = screenRecorder.current?.getDiagSnapshot?.() || null;+ const cameraDiag = cameraRecorder.current?.getDiagSnapshot?.() || null;+ if (screenDiag || cameraDiag) {+ const suspectedFailed =+ status !== "completed" ||+ (screenDiag && screenDiag.chunksOut === 0) ||+ (cameraDiag && cameraDiag.chunksOut === 0);+ const eventType = suspectedFailed+ ? "recording_failed_bundle"+ : "recording_stop_diag";+ let lifecycleBundle = null;+ if (suspectedFailed) {+ try {+ lifecycleBundle = await getCompressedLifecycleLog();+ } catch {}+ }+ void emitUploadTelemetry(eventType, {+ status,+ screenDiag,+ cameraDiag,+ lifecycleBundle,+ });+ }+ } catch {}const opfsSessionId =recorderSession.current.opfsSessionId || storageOpfsSessionId || sessionId;const usedOpfs = Object.values(@@ -4483,6 +4563,27 @@ const CloudRecorder = () => {};}, []);+ // 30s heartbeat snapshots WebCodecs counters mid-recording so a+ // session that dies before stop (tab kill, sleep, crash) still leaves+ // breadcrumbs at the server. WebCodecs only; MediaRecorder has no+ // equivalent counters.+ useEffect(() => {+ if (!started) return;+ const intervalId = setInterval(() => {+ try {+ if (!recorderSession.current?.id) return;+ const screen = screenRecorder.current?.getDiagSnapshot?.();+ const camera = cameraRecorder.current?.getDiagSnapshot?.();+ if (!screen && !camera) return;+ void emitUploadTelemetry("recording_heartbeat", {+ screenDiag: screen || null,+ cameraDiag: camera || null,+ });+ } catch {}+ }, 30_000);+ return () => clearInterval(intervalId);+ }, [started]);+const sendEditorReady = ({projectId,sceneId,diff --git a/src/pages/CloudRecorder/encoder/WebCodecsTrackRecorder.js b/src/pages/CloudRecorder/encoder/WebCodecsTrackRecorder.jsindex 67ad48a..c41a9f2 100644--- a/src/pages/CloudRecorder/encoder/WebCodecsTrackRecorder.js+++ b/src/pages/CloudRecorder/encoder/WebCodecsTrackRecorder.js@@ -58,6 +58,16 @@ export class WebCodecsTrackRecorder {return this._recorder?.actualVideoCodec || null;}+ // Diagnostic counters; safe to poll mid-recording and after stop.+ // Returns null before the inner recorder is constructed.+ getDiagSnapshot() {+ try {+ return this._recorder?.getDiagSnapshot?.() || null;+ } catch {+ return null;+ }+ }+start(_timeslice) {// timeslice is a no-op: Mp4MuxerWrapper emits on its own ~1s cadence.if (this._state !== "inactive") {diff --git a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js b/src/pages/Recorder/webcodecs/WebCodecsRecorder.jsindex 089d3e4..7df8a38 100644--- a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js+++ b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js@@ -257,6 +257,23 @@ export class WebCodecsRecorder {// One-shot: surfaces SPS+PPS bytes once for OPFS persistence so a// tab-kill recovery can reconstruct MP4 without the muxer.this._decoderConfigEmitted = false;++ // Diagnostic counters. The framesFromMSTP vs framesFed gap points to+ // MSTP-side issues; framesFed vs chunksOut catches the silent+ // no-output encoder bug.+ this._framesFed = 0;+ this._chunksOut = 0;+ this._framesFromMSTP = 0;+ this._staticFrameSyntheticCount = 0;+ this._firstChunkAt = null;+ this._encoderConstructCount = 0;+ this._videoEncoderStateAtStop = null;+ this._videoCodecConfigsTried = [];+ this._displaySurface = null;+ this._frameRateRequested = Number.isFinite(options?.fps) ? options.fps : null;+ this._frameRateActual = null;+ this._frameWidthActual = null;+ this._frameHeightActual = null;}async _probeRealResolution() {@@ -287,6 +304,15 @@ export class WebCodecsRecorder {: null;const w = settings && Number(settings.width);const h = settings && Number(settings.height);+ if (settings) {+ if (typeof settings.displaySurface === "string") {+ this._displaySurface = settings.displaySurface;+ }+ const fr = Number(settings.frameRate);+ if (Number.isFinite(fr) && fr > 0) this._frameRateActual = fr;+ if (Number.isFinite(w) && w > 0) this._frameWidthActual = w;+ if (Number.isFinite(h) && h > 0) this._frameHeightActual = h;+ }if (Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0) {this.log("[WCR] Resolution from track settings:", w, "x", h);return { width: w, height: h };@@ -766,6 +792,7 @@ export class WebCodecsRecorder {timestamp: tsUs,keyFrame: false,});+ this._framesFed += 1;} finally {hold.close();}@@ -797,6 +824,13 @@ export class WebCodecsRecorder {}}+ // Snapshot encoder state before finalize closes it.+ try {+ this._videoEncoderStateAtStop = this.videoEncoder?.state || "destroyed";+ } catch {+ this._videoEncoderStateAtStop = "unknown";+ }+// Zero chunks: don't ship a header-only file. Skips muxer.finalize// below and the err is NOT tagged finalized (nothing to salvage).if (shouldFailZeroChunksAtStop(this._firstChunkSeen, this.frameCount)) {@@ -874,6 +908,7 @@ export class WebCodecsRecorder {? { reason: this._swRetryReason || null }: null,lastFailureCode: this._lastFailureCode,+ diag: this.getDiagSnapshot(),});endOnFinalized({ ok: true });} catch (err) {@@ -894,6 +929,36 @@ export class WebCodecsRecorder {this._stopping = false;}+ // Read-only snapshot of the diagnostic counters and encoder choice.+ // Safe to call mid-recording and at stop; never throws.+ getDiagSnapshot() {+ let firstChunkLatencyMs = null;+ if (this._firstChunkAt != null && this._videoStartUs != null) {+ firstChunkLatencyMs = Math.round(+ this._firstChunkAt - this._videoStartUs / 1000,+ );+ }+ return {+ videoCodecString: this.actualVideoCodec || null,+ hardwareAccelerationActual:+ this._activeVideoConfig?.hardwareAcceleration || "no-preference",+ videoCodecConfigsTried: this._videoCodecConfigsTried.slice(0, 8),+ displaySurface: this._displaySurface,+ frameRateRequested: this._frameRateRequested,+ frameRateActual: this._frameRateActual,+ frameWidthActual: this._frameWidthActual,+ frameHeightActual: this._frameHeightActual,+ framesFed: this._framesFed,+ chunksOut: this._chunksOut,+ framesFromMSTP: this._framesFromMSTP,+ staticFrameSyntheticCount: this._staticFrameSyntheticCount,+ firstChunkLatencyMs,+ videoEncoderStateAtStop: this._videoEncoderStateAtStop,+ encoderConstructCount: this._encoderConstructCount,+ lastWebCodecsFailureCode: this._lastFailureCode || null,+ };+ }+pause() {this._pauseResumeChain = this._pauseResumeChain.catch(() => {})@@ -1305,8 +1370,10 @@ export class WebCodecsRecorder {// First encoded video chunk: the recording is producing real// bytes, so disarm the no-first-chunk watchdog and arm the// mid-stream stall watchdog instead.+ this._chunksOut += 1;if (!this._firstChunkSeen) {this._firstChunkSeen = true;+ this._firstChunkAt = performance.now();this._clearFirstChunkWatchdog();this._armMidStreamStallWatchdog();}@@ -1455,6 +1522,7 @@ export class WebCodecsRecorder {output: videoEncoderOutput,error: videoEncoderError,});+ this._encoderConstructCount += 1;// configure() can throw sync. retry hardware→software on quota/contention// (Teams/Zoom, NVIDIA 3-encoder cap); if SW also contends, cooldown and@@ -1503,6 +1571,7 @@ export class WebCodecsRecorder {output: videoEncoderOutput,error: videoEncoderError,});+ this._encoderConstructCount += 1;};const isContention = (err) => {const msg = String(err?.message || err || "");@@ -1923,6 +1992,7 @@ export class WebCodecsRecorder {this._videoEncoderErrorHandler(err);},});+ this._encoderConstructCount += 1;nextEncoder.configure(config);this.videoEncoder = nextEncoder;this._activeVideoConfig = config;@@ -2089,6 +2159,11 @@ export class WebCodecsRecorder {const test = new VideoEncoder({ output() {}, error() {} });try {test.configure(resolvedConfig);+ this._videoCodecConfigsTried.push({+ codec: c.codec,+ hw: c.hw,+ succeeded: true,+ });this.log("[WCR] Selected encoder:", c.codec, c.hw);try {chrome.storage.local.set({@@ -2110,6 +2185,11 @@ export class WebCodecsRecorder {containerCodec: c.containerCodec,};} catch (e) {+ this._videoCodecConfigsTried.push({+ codec: c.codec,+ hw: c.hw,+ succeeded: false,+ });} finally {try { test.close(); } catch {}}@@ -2218,9 +2298,11 @@ export class WebCodecsRecorder {continue;}isSynthetic = true;+ this._staticFrameSyntheticCount += 1;} else {if (readResult.done || !readResult.value) break;frame = readResult.value;+ this._framesFromMSTP += 1;// Drives the sleep-gap detection above.this._lastFrameArrivalAt = performance.now();@@ -2344,6 +2426,7 @@ export class WebCodecsRecorder {timestamp: tsUs,keyFrame,});+ this._framesFed += 1;} catch (encErr) {// Same race after the check. Only swallow when paused// so real encoder errors still surface.diff --git a/src/pages/utils/lifecycleLog.js b/src/pages/utils/lifecycleLog.jsindex 88b4008..5cd47b1 100644--- a/src/pages/utils/lifecycleLog.js+++ b/src/pages/utils/lifecycleLog.js@@ -67,3 +67,99 @@ export const getLifecycleLog = async () => {export const flushLifecycleLog = async () => {await _writeChain;};++// Allow-list for diagnostic bundling. Lifecycle `data` can hold+// arbitrary storage values (e.g. stringified error JSON), so a deny+// list isn't safe: one callsite stuffing a URL into an unexpected key+// would leak it. Only numeric/boolean counters and short strings get+// through, and new keys have to be added here on purpose.+const SAFE_DATA_KEYS = new Set([+ // countdown+ "runId", "countdownTimeS", "count", "elapsedMs", "endHoldMs",+ "endedAt", "startDispatchedAt", "postHideDelayMs", "ageMs",+ // start flow+ "attemptId", "caller", "tabId",+ // encoder selection+ "kind", "reason", "container",+ // recorder lifecycle+ "frame", "audioQ", "videoQ", "frameCount", "h", "w", "framerate",+ "height", "width", "chunks", "durMs", "ok", "codec",+ // status / flag transitions+ "isRecording", "isTargetTab", "recordingType", "isTarget", "cancelled",+ "filename", "beep", "wasPreloaded",+ // back-to-back / restart context+ "backup", "backupSetup", "memoryError", "offscreen", "pendingRecording",+ "recording", "restarting", "region", "sandboxTab",+]);+const MAX_SAFE_STRING_LEN = 32;++const scrubValue = (v) => {+ if (v == null) return v;+ if (typeof v === "number" || typeof v === "boolean") return v;+ if (typeof v === "string") {+ return v.length > MAX_SAFE_STRING_LEN ? undefined : v;+ }+ return undefined;+};++const scrubData = (data) => {+ if (data == null || typeof data !== "object") return scrubValue(data);+ if (Array.isArray(data)) {+ return data+ .slice(0, 16)+ .map(scrubValue)+ .filter((v) => v !== undefined);+ }+ const out = {};+ for (const [k, v] of Object.entries(data)) {+ if (!SAFE_DATA_KEYS.has(k)) continue;+ const scrubbed = scrubValue(v);+ if (scrubbed !== undefined) out[k] = scrubbed;+ }+ return out;+};++const scrubEntry = (e) => {+ if (!e || typeof e !== "object") return null;+ const out = {+ ts: Number.isFinite(e.ts) ? e.ts : null,+ src: typeof e.src === "string" ? e.src.slice(0, 64) : "?",+ ev: typeof e.ev === "string" ? e.ev.slice(0, 64) : "?",+ };+ if (e.data !== undefined) out.data = scrubData(e.data);+ return out;+};++/**+ * gzip+base64 snapshot of the scrubbed lifecycle log, capped at ~96KB+ * compressed. For failed-recording bundles only; returns null on failure.+ */+export const getCompressedLifecycleLog = async () => {+ try {+ const { default: pako } = await import("pako");+ const log = await getLifecycleLog();+ let scrubbed = log.map(scrubEntry).filter(Boolean);+ // Enforce the cap after gzip; if over, drop oldest entries since the+ // newest matter most for an end-of-recording bundle.+ let payload = null;+ let rawBytes = 0;+ for (let attempt = 0; attempt < 8; attempt += 1) {+ const json = JSON.stringify(scrubbed);+ const gz = pako.gzip(json);+ rawBytes = gz.length;+ let bin = "";+ for (let i = 0; i < gz.length; i += 1) bin += String.fromCharCode(gz[i]);+ const b64 = btoa(bin);+ if (b64.length <= 96 * 1024) {+ payload = b64;+ break;+ }+ if (scrubbed.length <= 4) break;+ scrubbed = scrubbed.slice(Math.ceil(scrubbed.length / 2));+ }+ if (!payload) return null;+ return { encoding: "gzip+base64", payload, rawBytes };+ } catch {+ return null;+ }+};