Skip to content

The free and privacy-friendly screen recorder with no limits 🎥

macOS system audio via getDisplayMedia, WebCodecs stall recovery, and off-thread editor duration fix

Alyssa Xa49795c6cb3d
diff --git a/package-lock.json b/package-lock.json
index 802dc48..7a07f1c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "screenity",
- "version": "4.4.11",
+ "version": "4.4.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "screenity",
- "version": "4.4.11",
+ "version": "4.4.13",
"hasInstallScript": true,
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.27.1",
@@ -36,7 +36,7 @@
"gif.js": "^0.2.0",
"jszip": "^3.10.1",
"localforage": "^1.10.0",
- "mediabunny": "^1.45.3",
+ "mediabunny": "^1.46.0",
"patch-package": "^8.0.0",
"plyr": "3.7.8",
"plyr-react": "^5.3.0",
@@ -8430,9 +8430,9 @@
}
},
"node_modules/mediabunny": {
- "version": "1.45.3",
- "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.45.3.tgz",
- "integrity": "sha512-GUCPYjR+5olLM7DRmupCXCmZkkSrKHVl1gyW2RztpObqLfrix19kWGf/9WgWzDW0g49DvfGXpl+zfArCx5HDMQ==",
+ "version": "1.46.0",
+ "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.46.0.tgz",
+ "integrity": "sha512-HIaMQ6PVMndrFb9sNCh9/uAsLFBfLzyAgbk3kN7ZqlRRq//9RPYqIOQtXYpkbWBZU8ZJkaAUNLDtwTcdKo7yQw==",
"license": "MPL-2.0",
"workspaces": [
".",
diff --git a/package.json b/package.json
index 7c8cc54..e5c65de 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "screenity",
- "version": "4.4.12",
+ "version": "4.4.14",
"description": "The free and privacy-friendly screen recorder with no sign in needed.",
"scripts": {
"build": "cross-env NODE_ENV=production node utils/build.js",
@@ -63,7 +63,7 @@
"gif.js": "^0.2.0",
"jszip": "^3.10.1",
"localforage": "^1.10.0",
- "mediabunny": "^1.45.3",
+ "mediabunny": "^1.46.0",
"patch-package": "^8.0.0",
"plyr": "3.7.8",
"plyr-react": "^5.3.0",
diff --git a/src/_locales/ca/messages.json b/src/_locales/ca/messages.json
index ccc52e4..31fc553 100644
--- a/src/_locales/ca/messages.json
+++ b/src/_locales/ca/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Inicia sessió per guardar els vídeos al núvol, compartir amb enllaç i accedir a funcions avançades d'edició.",
+ "message": "Comparteix les gravacions amb un enllaç net, desa-les al núvol i afegeix zooms, subtítols i dissenys, quan ho necessitis.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Inicia sessió per desbloquejar funcions Pro",
+ "message": "Desbloqueja l'editor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json
index 6b322de..d6f72e3 100644
--- a/src/_locales/de/messages.json
+++ b/src/_locales/de/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Melde dich an, um Videos in der Cloud zu speichern, per Link zu teilen und auf erweiterte Bearbeitung zuzugreifen.",
+ "message": "Teile Aufnahmen per sauberem Link, speichere sie in der Cloud und füge Zooms, Untertitel und Layouts hinzu, wann immer du es brauchst.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Anmelden, um Pro-Funktionen freizuschalten",
+ "message": "Editor freischalten",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 2c98490..5bb1c88 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -1422,11 +1422,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Sign in to save your videos to the cloud, share with a link, and access advanced editing features.",
+ "message": "Share recordings with a clean link, save them to the cloud, and add zooms, captions, and layouts, if and when you need it.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Sign in to unlock paid features",
+ "message": "Unlock the editor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/es/messages.json b/src/_locales/es/messages.json
index 9817241..15745b1 100644
--- a/src/_locales/es/messages.json
+++ b/src/_locales/es/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Inicia sesión para guardar los vídeos en la nube, compartir con enlace y acceder a funciones avanzadas de edición.",
+ "message": "Comparte tus grabaciones con un enlace limpio, guárdalas en la nube y añade zooms, subtítulos y diseños, cuando lo necesites.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Inicia sesión para desbloquear funciones Pro",
+ "message": "Desbloquea el editor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/fr/messages.json b/src/_locales/fr/messages.json
index 01283c6..4e930f0 100644
--- a/src/_locales/fr/messages.json
+++ b/src/_locales/fr/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Connectez-vous pour sauvegarder vos vidéos dans le cloud, les partager par lien et accéder à des outils de montage avancés.",
+ "message": "Partagez vos enregistrements via un lien clair, enregistrez-les dans le cloud et ajoutez des zooms, des sous-titres et des mises en page, si et quand vous en avez besoin.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Connectez-vous pour débloquer les fonctionnalités Pro",
+ "message": "Débloquez l'éditeur",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/hi/messages.json b/src/_locales/hi/messages.json
index a63a99b..80dac69 100644
--- a/src/_locales/hi/messages.json
+++ b/src/_locales/hi/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "अपने वीडियो क्लाउड में सेव करने, लिंक के साथ साझा करने और एडवांस एडिटिंग फीचर्स एक्सेस करने के लिए साइन इन करें।",
+ "message": "रिकॉर्डिंग को एक साफ़ लिंक से शेयर करें, उन्हें क्लाउड में सेव करें, और ज़रूरत पड़ने पर ज़ूम, कैप्शन और लेआउट जोड़ें।",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "पेड फीचर्स अनलॉक करने के लिए साइन इन करें",
+ "message": "एडिटर अनलॉक करें",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/id/messages.json b/src/_locales/id/messages.json
index 0c7684a..e39698e 100644
--- a/src/_locales/id/messages.json
+++ b/src/_locales/id/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Masuk untuk menyimpan video ke cloud, berbagi dengan tautan, dan akses fitur editing lanjutan.",
+ "message": "Bagikan rekaman lewat tautan yang rapi, simpan di cloud, dan tambahkan zoom, teks, dan tata letak, kapan pun kamu membutuhkannya.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Masuk untuk membuka fitur berbayar",
+ "message": "Buka editor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/it/messages.json b/src/_locales/it/messages.json
index bfed528..8e94ff3 100644
--- a/src/_locales/it/messages.json
+++ b/src/_locales/it/messages.json
@@ -1318,11 +1318,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Accedi per salvare i video sul cloud, condividerli con un link e accedere a funzioni di editing avanzate.",
+ "message": "Condividi le registrazioni con un link pulito, salvale nel cloud e aggiungi zoom, sottotitoli e layout, se e quando ti serve.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Accedi per sbloccare le funzioni Pro",
+ "message": "Sblocca l'editor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/ko/messages.json b/src/_locales/ko/messages.json
index e0a4c08..34ca27f 100644
--- a/src/_locales/ko/messages.json
+++ b/src/_locales/ko/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "영상을 클라우드에 저장하고 링크로 공유하며 고급 편집 기능을 사용하려면 로그인하세요.",
+ "message": "녹화를 깔끔한 링크로 공유하고 클라우드에 저장하며, 필요할 때 줌, 자막, 레이아웃을 추가하세요.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "유료 기능 잠금 해제를 위해 로그인",
+ "message": "에디터 잠금 해제",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/pl/messages.json b/src/_locales/pl/messages.json
index 6d89c1d..7d1ada7 100644
--- a/src/_locales/pl/messages.json
+++ b/src/_locales/pl/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Zaloguj się, aby zapisać nagrania w chmurze, udostępniać linkiem i korzystać z zaawansowanych opcji edycji.",
+ "message": "Udostępniaj nagrania przez czytelny link, zapisuj je w chmurze i dodawaj zoomy, napisy i układy, jeśli i kiedy tego potrzebujesz.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Zaloguj się, aby odblokować funkcje Pro",
+ "message": "Odblokuj edytor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/pt_BR/messages.json b/src/_locales/pt_BR/messages.json
index 169e36e..f72daef 100644
--- a/src/_locales/pt_BR/messages.json
+++ b/src/_locales/pt_BR/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Faça login para salvar os vídeos na nuvem, compartilhar por link e acessar recursos avançados de edição.",
+ "message": "Compartilhe gravações com um link limpo, salve-as na nuvem e adicione zooms, legendas e layouts, se e quando precisar.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Faça login para desbloquear recursos Pro",
+ "message": "Desbloqueie o editor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/pt_PT/messages.json b/src/_locales/pt_PT/messages.json
index c79ad5d..20259c0 100644
--- a/src/_locales/pt_PT/messages.json
+++ b/src/_locales/pt_PT/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Inicia sessão para guardar os vídeos na cloud, partilhar com ligação e aceder a funcionalidades avançadas de edição.",
+ "message": "Partilha gravações com um link limpo, guarda-as na nuvem e adiciona zooms, legendas e esquemas, se e quando precisares.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Inicia sessão para desbloquear funcionalidades Pro",
+ "message": "Desbloqueia o editor",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/ru/messages.json b/src/_locales/ru/messages.json
index 78d7346..4f3659b 100644
--- a/src/_locales/ru/messages.json
+++ b/src/_locales/ru/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Войдите, чтобы сохранить видео в облако, делиться ссылкой и использовать расширенное редактирование.",
+ "message": "Делитесь записями по аккуратной ссылке, сохраняйте их в облаке и добавляйте зумы, субтитры и макеты, если и когда понадобится.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Войти, чтобы открыть платные функции",
+ "message": "Разблокировать редактор",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/ta/messages.json b/src/_locales/ta/messages.json
index d604a16..d5fa250 100644
--- a/src/_locales/ta/messages.json
+++ b/src/_locales/ta/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "შედით, რომ შეინახოთ ვიდეოები ღრუბელში, გაუზიაროთ ბმულით და გამოიყენოთ დამატებითი რედაქტირების ფუნქციები.",
+ "message": "பதிவுகளை ஒரு சுத்தமான இணைப்பின் மூலம் பகிரவும், அவற்றை கிளவுட்டில் சேமிக்கவும், தேவைப்படும்போது ஜூம், வசன வரிகள் மற்றும் தளவமைப்புகளைச் சேர்க்கவும்.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "შედით ფასიანი ფუნქციების გასახსნელად",
+ "message": "எடிட்டரைத் திறக்கவும்",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/tr/messages.json b/src/_locales/tr/messages.json
index d2b2431..2466e2c 100644
--- a/src/_locales/tr/messages.json
+++ b/src/_locales/tr/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Videolarını buluta kaydetmek, bağlantıyla paylaşmak ve gelişmiş düzenleme özelliklerine erişmek için giriş yap.",
+ "message": "Kayıtları temiz bir bağlantıyla paylaş, bulutta sakla ve gerektiğinde yakınlaştırmalar, altyazılar ve düzenler ekle.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Ücretli özelliklerin kilidini açmak için giriş yap",
+ "message": "Editörün kilidini aç",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/uk/messages.json b/src/_locales/uk/messages.json
index a911bc5..6d59c7b 100644
--- a/src/_locales/uk/messages.json
+++ b/src/_locales/uk/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "Увійдіть, щоб зберігати відео в хмарі, ділитися посиланням і редагувати з розширеними функціями.",
+ "message": "Діліться записами за допомогою акуратного посилання, зберігайте їх у хмарі та додавайте зуми, субтитри й макети, якщо і коли це знадобиться.",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "Увійти, щоб відкрити платні функції",
+ "message": "Розблокувати редактор",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/zh_CN/messages.json b/src/_locales/zh_CN/messages.json
index 40ddef1..4b70f67 100644
--- a/src/_locales/zh_CN/messages.json
+++ b/src/_locales/zh_CN/messages.json
@@ -1334,11 +1334,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "登录即可将视频保存到云端、生成分享链接并使用高级编辑功能。",
+ "message": "用简洁的链接分享录制内容,保存到云端,并在需要时添加缩放、字幕和布局。",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "登录以解锁付费功能",
+ "message": "解锁编辑器",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/_locales/zh_TW/messages.json b/src/_locales/zh_TW/messages.json
index 4db4622..b5873e4 100644
--- a/src/_locales/zh_TW/messages.json
+++ b/src/_locales/zh_TW/messages.json
@@ -1338,11 +1338,11 @@
"description": "Title for the welcome Pro popup"
},
"welcomeProDescription": {
- "message": "登入即可將影片儲存至雲端、使用連結分享,並存取進階編輯功能。",
+ "message": "用簡潔的連結分享錄製內容,儲存到雲端,並在需要時加入縮放、字幕和版面配置。",
"description": "Description for the welcome Pro popup"
},
"welcomeProButton": {
- "message": "登入以解鎖付費功能",
+ "message": "解鎖編輯器",
"description": "Button to sign in to Screenity Pro"
},
"welcomeProSupport": {
diff --git a/src/manifest.json b/src/manifest.json
index 06e73e5..64afea9 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.12",
+ "version": "4.4.14",
"background": {
"service_worker": "background.bundle.js"
},
diff --git a/src/pages/Background/listeners/onInstalledListener.js b/src/pages/Background/listeners/onInstalledListener.js
index cbacada..1528b6c 100644
--- a/src/pages/Background/listeners/onInstalledListener.js
+++ b/src/pages/Background/listeners/onInstalledListener.js
@@ -9,18 +9,13 @@ const cloudFeaturesEnabled =
export const onInstalledListener = () => {
chrome.runtime.onInstalled.addListener(async (details) => {
const version = chrome.runtime.getManifest().version;
- const locale = chrome.i18n.getMessage("@@ui_locale");
if (details.reason === "install") {
chrome.storage.local.clear();
const installQs = await supportContextQuery({ source: "uninstall" });
const installUrl = `https://tally.so/r/w8Zro5?${installQs}`;
- chrome.runtime.setUninstallURL(
- locale.includes("en")
- ? installUrl
- : `http://translate.google.com/translate?js=n&sl=auto&tl=${locale}&u=${encodeURIComponent(installUrl)}`
- );
+ chrome.runtime.setUninstallURL(installUrl);
chrome.storage.local.set({
firstTime: true,
@@ -60,11 +55,7 @@ export const onInstalledListener = () => {
const updateQs = await supportContextQuery({ source: "uninstall" });
const updateUrl = `https://tally.so/r/3Ex6kX?${updateQs}`;
- chrome.runtime.setUninstallURL(
- locale.includes("en")
- ? updateUrl
- : `http://translate.google.com/translate?js=n&sl=auto&tl=${locale}&u=${encodeURIComponent(updateUrl)}`
- );
+ chrome.runtime.setUninstallURL(updateUrl);
}
// Backup mode is deprecated: hidden from the settings dropdown and
diff --git a/src/pages/Background/messaging/handlers.js b/src/pages/Background/messaging/handlers.js
index 220be0f..d67d08a 100644
--- a/src/pages/Background/messaging/handlers.js
+++ b/src/pages/Background/messaging/handlers.js
@@ -517,7 +517,7 @@ export const handleFinishMultiRecording = async () => {
markProjectPublic(multiProjectId);
- createTab(url, true, true).then(() => {
+ createTab(url, true).then(() => {
if (publicUrl) {
copyToClipboard(publicUrl);
chrome.runtime.sendMessage({
@@ -1431,6 +1431,8 @@ export const setupHandlers = () => {
"cloudrecorder-",
"camera-",
"editor-",
+ // AudioContext interrupt/resume from attachAudioContextWatchdog (page realm).
+ "audiocontext-",
];
if (!allowedPrefixes.some((p) => ev.startsWith(p))) return;
diagEvent(ev, message?.data ?? null);
@@ -1503,7 +1505,7 @@ export const setupHandlers = () => {
}
}
- const tab = await createTab("download.html", true, true);
+ const tab = await createTab("download.html", true);
if (!tab?.id) return;
chrome.tabs.onUpdated.addListener(function listener(tabId, info) {
if (info.status === "complete" && tabId === tab.id) {
@@ -1516,45 +1518,47 @@ export const setupHandlers = () => {
registerMessage("review-screenity", () =>
createTab(
"https://chrome.google.com/webstore/detail/screenity-screen-recorder/kbbdabhdfibnancpjfhlkhafgdilcnji/reviews",
- false,
true,
),
);
registerMessage("follow-twitter", () =>
- createTab("https://alyssax.substack.com/", false, true),
- );
- registerMessage("pricing", () =>
- createTab("https://screenity.io/pro", false, true),
+ createTab("https://alyssax.substack.com/", true),
);
+ registerMessage("pricing", (message) => {
+ const source =
+ typeof message?.source === "string" && message.source
+ ? message.source
+ : "extension";
+ return createTab(
+ `https://screenity.io/?ref=${encodeURIComponent(source)}`,
+ true,
+ );
+ });
registerMessage("open-processing-info", () =>
createTab(
"https://help.screenity.io/editing-and-exporting/dJRFpGq56JFKC7k8zEvsqb/why-is-there-a-5-minute-limit-for-editing/ddy4e4TpbnrFJ8VoRT37tQ",
true,
- true,
),
);
registerMessage("upgrade-info", () =>
createTab(
"https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what-are-the-technical-requirements-for-using-screenity/6kdB6qru6naVD8ZLFvX3m9",
true,
- true,
),
);
registerMessage("trim-info", () =>
createTab(
"https://help.screenity.io/editing-and-exporting/dJRFpGq56JFKC7k8zEvsqb/how-to-cut-trim-or-mute-parts-of-your-video/svNbM7YHYY717MuSWXrKXH",
true,
- true,
),
);
registerMessage("join-waitlist", () =>
- createTab("https://tally.so/r/npojNV", true, true),
+ createTab("https://tally.so/r/npojNV", true),
);
registerMessage("chrome-update-info", () =>
createTab(
"https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what-are-the-technical-requirements-for-using-screenity/6kdB6qru6naVD8ZLFvX3m9",
true,
- true,
),
);
registerMessage("set-surface", (message) => setSurface(message));
@@ -1562,17 +1566,16 @@ export const setupHandlers = () => {
registerMessage("pip-started", () => handlePip(true));
registerMessage("sign-out-drive", (message) => handleSignOutDrive(message));
registerMessage("open-help", () =>
- createTab("https://help.screenity.io/", true, true),
+ createTab("https://help.screenity.io/", true),
);
registerMessage("memory-limit-help", () =>
createTab(
"https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/what-does-%E2%80%9Cmemory-limit-reached%E2%80%9D-mean-when-recording/8WkwHbt3puuXunYqQnyPcb",
true,
- true,
),
);
registerMessage("open-home", () =>
- createTab("https://screenity.io/", false, true),
+ createTab("https://screenity.io/", true),
);
registerMessage("report-bug", async (message) => {
const qs = await supportContextQuery({
@@ -1580,7 +1583,7 @@ export const setupHandlers = () => {
source: "settings",
});
const zipParam = message?.zipBundled ? "&zipBundled=1" : "";
- createTab(`https://tally.so/r/3ElpXq?${qs}${zipParam}`, false, true);
+ createTab(`https://tally.so/r/3ElpXq?${qs}${zipParam}`, true);
});
registerMessage("report-error", async (message) => {
const errorCode = message?.errorCode || null;
@@ -1609,9 +1612,9 @@ export const setupHandlers = () => {
const zipParam = message?.zipBundled ? "&zipBundled=1" : "";
if (isLoggedIn) {
- createTab(`https://tally.so/r/310MNg?extension=true&${qs}`, false, true);
+ createTab(`https://tally.so/r/310MNg?extension=true&${qs}`, true);
} else {
- createTab(`https://tally.so/r/3ElpXq?feedbackType=Bug&${qs}${zipParam}`, false, true);
+ createTab(`https://tally.so/r/3ElpXq?feedbackType=Bug&${qs}${zipParam}`, true);
}
});
registerMessage("clear-recordings", () => clearAllRecordings());
@@ -1748,22 +1751,24 @@ export const setupHandlers = () => {
registerMessage("extension-media-permissions", () =>
createTab(
`chrome://settings/content/siteDetails?site=chrome-extension://${chrome.runtime.id}`,
- false,
true,
),
);
registerMessage("add-alarm-listener", (payload) => addAlarmListener(payload));
registerMessage(
"check-auth-status",
- async () => {
+ async (message) => {
if (!CLOUD_FEATURES_ENABLED) {
return {
authenticated: false,
message: "Cloud features disabled",
};
}
- // force so a fresh web login is picked up even after explicit logout.
- return await loginWithWebsite({ force: true });
+ // Force a fresh web-login pickup by default, but let callers opt out.
+ // The popup mount opts out so a fresh install doesn't silently revive
+ // auth from a leftover website cookie (it would flash the paid welcome
+ // screen at a returning user who should just see "Log in").
+ return await loginWithWebsite({ force: message?.force !== false });
},
);
registerMessage(
@@ -2528,7 +2533,7 @@ export const setupHandlers = () => {
}
const url = `${process.env.SCREENITY_APP_BASE}/?settings=open`;
- createTab(url, true, true);
+ createTab(url, true);
});
registerMessage("open-support", async () => {
if (!CLOUD_FEATURES_ENABLED) {
@@ -2548,7 +2553,7 @@ export const setupHandlers = () => {
user: { name, email },
});
const url = `https://tally.so/r/310MNg?extension=true&${qs}`;
- createTab(url, true, true);
+ createTab(url, true);
});
registerMessage("check-banner-support", async (message, sendResponse) => {
const { bannerSupport } = await chrome.storage.local.get(["bannerSupport"]);
diff --git a/src/pages/Background/recording/restoreCloudRecording.js b/src/pages/Background/recording/restoreCloudRecording.js
index f01a8f8..ee80741 100644
--- a/src/pages/Background/recording/restoreCloudRecording.js
+++ b/src/pages/Background/recording/restoreCloudRecording.js
@@ -76,7 +76,7 @@ export const restoreCloudRecording = async () => {
await resetWatchdogState();
- const tab = await createTab("download.html", true, true);
+ const tab = await createTab("download.html", true);
if (!tab?.id) return;
let settled = false;
diff --git a/src/pages/Background/recording/startRecording.js b/src/pages/Background/recording/startRecording.js
index c5e348c..04e2b2d 100644
--- a/src/pages/Background/recording/startRecording.js
+++ b/src/pages/Background/recording/startRecording.js
@@ -331,6 +331,13 @@ const _startRecordingInner = async (caller) => {
]);
await initDiagSession({
recordingAttemptId,
+ // Chrome major pins each session to a version so the local diagnostic
+ // zip can be read against version-gated browser fixes.
+ browserMajor: (() => {
+ const ua = (typeof navigator !== "undefined" && navigator.userAgent) || "";
+ const m = ua.match(/Chrome\/([0-9]+)/);
+ return m ? parseInt(m[1], 10) : null;
+ })(),
recordingType: recordingType || "screen",
quality: quality || null,
region: Boolean(customRegion),
@@ -355,6 +362,7 @@ const _startRecordingInner = async (caller) => {
const [extras, tabs, wins] = await Promise.all([
chrome.storage.local.get([
"screenityUser",
+ "qualityValue",
"fpsValue",
"cameraActive",
"micActive",
@@ -379,7 +387,10 @@ const _startRecordingInner = async (caller) => {
? navigator.hardwareConcurrency
: null,
recordingType: recordingType || "screen",
- qualityValue: quality || null,
+ // Storage canonical key is qualityValue, not quality. `quality`
+ // is unset on this read path; reading it returned undefined and
+ // surfaced as null on every beacon.
+ qualityValue: extras?.qualityValue || null,
fpsValue: extras?.fpsValue || null,
cameraActive: Boolean(extras?.cameraActive),
micActive: Boolean(extras?.micActive),
diff --git a/src/pages/Background/tabManagement/createTab.js b/src/pages/Background/tabManagement/createTab.js
index c2a02f9..43f29c1 100644
--- a/src/pages/Background/tabManagement/createTab.js
+++ b/src/pages/Background/tabManagement/createTab.js
@@ -1,17 +1,6 @@
-export const createTab = async (url, translate = false, active = false) => {
+export const createTab = async (url, active = false) => {
if (!url) return;
- if (translate) {
- const locale = chrome.i18n.getMessage("@@ui_locale");
- if (!locale.includes("en")) {
- url =
- "http://translate.google.com/translate?js=n&sl=auto&tl=" +
- locale +
- "&u=" +
- url;
- }
- }
-
return new Promise((resolve) => {
chrome.tabs.create(
{
diff --git a/src/pages/Background/tabManagement/editorTab.js b/src/pages/Background/tabManagement/editorTab.js
index 6f4f511..6e3eabc 100644
--- a/src/pages/Background/tabManagement/editorTab.js
+++ b/src/pages/Background/tabManagement/editorTab.js
@@ -269,7 +269,7 @@ export const resolveEditorTabForTarget = async ({
return { tabId: null, reused: false, opened: false };
}
- const createdTab = await createTab(targetUrl, true, true);
+ const createdTab = await createTab(targetUrl, true);
if (!createdTab?.id) {
console.warn("[Screenity][BG] Failed to open fallback editor tab", {
reason,
diff --git a/src/pages/CloudRecorder/CloudRecorder.jsx b/src/pages/CloudRecorder/CloudRecorder.jsx
index f6c62a9..2fc5d2f 100644
--- a/src/pages/CloudRecorder/CloudRecorder.jsx
+++ b/src/pages/CloudRecorder/CloudRecorder.jsx
@@ -17,6 +17,8 @@ import {
} from "../utils/tabKeepalive";
import { traceStep } from "../utils/startFlowTrace";
import { IS_OFFSCREEN_HOST } from "../utils/recordingHost";
+import { shouldUseDisplayMediaForScreen } from "../utils/screenCaptureMode";
+import { acquireDisplayMediaWithFocusRetry } from "../utils/acquireDisplayMedia";
import { startPrewarm, stopPrewarm } from "../Recorder/streamWarmup";
import { preloadWebCodecsModules } from "../Recorder/webcodecs/WebCodecsRecorder";
import {
@@ -279,6 +281,9 @@ const CloudRecorder = () => {
const recoveryExportedRef = useRef(false);
const screenTrackLostRef = useRef(false);
const screenTrackMonitor = useRef(null);
+ // Capture identity (recordingType/surface enums only, no labels/URLs) for
+ // forensic telemetry, so a frozen session's capture mechanism is known.
+ const captureContextRef = useRef(null);
const pausedStateRef = useRef(false);
const audioCaptureDegradedRef = useRef(false);
const storagePressureRef = useRef({
@@ -337,6 +342,9 @@ const CloudRecorder = () => {
const isInit = useRef(false);
const aCtx = useRef(null);
+ // Live AudioContext interruption stats from attachAudioContextWatchdog,
+ // folded into the audio diag snapshot at finalize for upload telemetry.
+ const audioHealthRef = useRef(null);
const destination = useRef(null);
const keepAliveInterval = useRef(null);
@@ -671,6 +679,15 @@ const CloudRecorder = () => {
screenStorageBackend: eventPayload.screenStorageBackend || null,
cameraStorageBackend: eventPayload.cameraStorageBackend || null,
audioStorageBackend: eventPayload.audioStorageBackend || null,
+ // Diagnostic event fields. Only populated on the diagnostic
+ // event types (recording_heartbeat, recording_stop_diag,
+ // recording_failed_bundle); null otherwise. The server
+ // sanitizer drops them cleanly when absent.
+ screenDiag: eventPayload.screenDiag || null,
+ cameraDiag: eventPayload.cameraDiag || null,
+ audioDiag: eventPayload.audioDiag || null,
+ lifecycleBundle: eventPayload.lifecycleBundle || null,
+ status: eventPayload.status || null,
},
};
};
@@ -753,6 +770,28 @@ const CloudRecorder = () => {
}
};
+ // Stamps a lifecycle/focus/track event with ms-since-start so a frozen
+ // session can be reconstructed. Enums and ms only, no labels/URLs/titles.
+ const logForensicEvent = (name, extra = {}) => {
+ try {
+ const startedAt = recorderSession.current?.startedAt || null;
+ // Only during an active recording; capture-context is exempt (fires at acquire).
+ if (!startedAt && name !== "capture-context") return;
+ const host = IS_OFFSCREEN_HOST
+ ? "offscreen"
+ : IS_IFRAME_CONTEXT
+ ? "iframe"
+ : "tab";
+ void emitUploadTelemetry("recording_forensic_event", {
+ name,
+ tMs: startedAt ? Date.now() - startedAt : null,
+ host,
+ ...(captureContextRef.current || {}),
+ ...extra,
+ });
+ } catch {}
+ };
+
const emitRecordingOutcome = (outcome, extra = {}) => {
const session = recorderSession.current;
const startedAt = session?.startedAt || null;
@@ -1154,6 +1193,17 @@ const CloudRecorder = () => {
const bindScreenTrack = (track) => {
if (!track) return;
screenTrackLostRef.current = false;
+ // Capture identity from the bound track (fires on every acquisition path).
+ // Enums and booleans only, no track.label/title/URL.
+ try {
+ captureContextRef.current = {
+ recordingType: recordingType.current || null,
+ displaySurface: track.getSettings?.().displaySurface || null,
+ isTab: !!isTab.current,
+ region: Boolean(regionRef.current),
+ };
+ logForensicEvent("capture-context");
+ } catch {}
logScreenTrackEvent("track-start", track);
track.onended = () => {
@@ -1183,6 +1233,12 @@ const CloudRecorder = () => {
console.error("🔴 Screen track ended unexpectedly!", diagnosticInfo);
+ // Forward to remote, redacting the window/tab label the local diag keeps.
+ logForensicEvent("screen-track-ended", {
+ readyState: track?.readyState || null,
+ hasChunks: hasChunks.current,
+ });
+
chrome.storage.local.set({
screenTrackLost: true,
lastTrackEndedEvent: diagnosticInfo,
@@ -1199,10 +1255,12 @@ const CloudRecorder = () => {
track.onmute = () => {
screenTrackLostRef.current = true;
logScreenTrackEvent("track-muted", track);
+ logForensicEvent("screen-track-muted");
};
track.onunmute = () => {
screenTrackLostRef.current = false;
logScreenTrackEvent("track-unmuted", track);
+ logForensicEvent("screen-track-unmuted");
};
startScreenTrackMonitor();
@@ -1785,6 +1843,66 @@ const CloudRecorder = () => {
return true;
};
+ // Audio (mic) diagnostic snapshot for the MediaRecorder audio path.
+ // The WebCodecs recorders expose getDiagSnapshot(); MediaRecorder does
+ // not, so we assemble an equivalent from the existing sessionTrackState
+ // counters plus the live mic-track + intent state. This is the one path
+ // the WebCodecs telemetry never covered, which is exactly where the
+ // silent empty-audio failures live.
+ //
+ // Returns null ONLY when the mic was not part of this recording (nothing
+ // to observe). When the user chose the mic we always return a snapshot,
+ // even at zero bytes, so an empty audio track stays observable. Pure
+ // reads — never mutates state, never throws.
+ const getAudioDiagSnapshot = () => {
+ try {
+ const micChosen = audioIntent.current?.micActive === true;
+ const hasUploader = Boolean(audioUploader.current);
+ const hasRecorder = Boolean(audioRecorder.current);
+ if (!micChosen && !hasUploader && !hasRecorder) return null;
+
+ const track = rawMicStream.current?.getAudioTracks?.()[0] || null;
+ const audioState = sessionTrackState.current?.audio || {};
+ const uploaderMeta = audioUploader.current?.getMeta?.() || null;
+ return {
+ // Authoritative user intent — the disambiguator that keeps a
+ // user-disabled mic from ever being read as a failure.
+ micChosen,
+ encoderKind: encoderKinds.audio || null,
+ recorderState: audioRecorder.current?.state || null,
+ // Live mic-track health. A missing/ended/system-muted track with
+ // micChosen=true is the genuine fault signature.
+ trackCount: rawMicStream.current?.getAudioTracks?.().length || 0,
+ trackReadyState: track?.readyState || null,
+ trackMuted: track ? Boolean(track.muted) : null,
+ trackEnabled: track ? Boolean(track.enabled) : null,
+ // Data flow. chunksOut === 0 with micChosen=true === empty audio.
+ chunksOut: audioState.chunkCount || 0,
+ bytesRecorded: audioState.bytesRecorded || 0,
+ durableChunkCount: audioState.durableChunkCount || 0,
+ lastChunkAt: audioState.lastChunkAt || null,
+ captureDegraded: Boolean(audioCaptureDegradedRef.current),
+ uploaderStatus: uploaderMeta?.status || null,
+ uploaderOffset:
+ typeof uploaderMeta?.offset === "number" ? uploaderMeta.offset : null,
+ // Throttling context: a backgrounded tab starves MediaRecorder.
+ documentHidden:
+ typeof document !== "undefined" ? document.hidden : null,
+ visibilityState:
+ typeof document !== "undefined" ? document.visibilityState : null,
+ // AudioContext interruption cause-signal: an OS "interrupted" state
+ // feeds the destination silence, so chunksOut===0 here with
+ // sawInterrupted distinguishes a silent gap from a dead mic track.
+ audioContextState: aCtx.current?.state ?? null,
+ audioInterruptedCount: audioHealthRef.current?.interruptedCount ?? 0,
+ audioInterruptedMs: audioHealthRef.current?.interruptedTotalMs ?? 0,
+ audioSawInterrupted: audioHealthRef.current?.sawInterrupted ?? false,
+ };
+ } catch {
+ return null;
+ }
+ };
+
const finalizeRecorderSession = async (
status = "completed",
{ keepOpfsSession = false } = {},
@@ -1798,11 +1916,28 @@ const CloudRecorder = () => {
try {
const screenDiag = screenRecorder.current?.getDiagSnapshot?.() || null;
const cameraDiag = cameraRecorder.current?.getDiagSnapshot?.() || null;
- if (screenDiag || cameraDiag) {
+ const audioDiag = getAudioDiagSnapshot();
+ if (screenDiag || cameraDiag || audioDiag) {
+ // Mic was chosen but the audio track produced zero bytes while
+ // another track recorded fine — the silent-audio failure. We read
+ // "did another track record" from sessionTrackState (populated for
+ // every encoder kind) rather than the WebCodecs diags, so this
+ // still fires when screen/camera run on MediaRecorder (no diag).
+ // Requiring otherTrackRecorded keeps trivially-short / fully-failed
+ // recordings from being flagged here.
+ const otherTrackRecorded =
+ (sessionTrackState.current.screen?.bytesRecorded || 0) > 0 ||
+ (sessionTrackState.current.camera?.bytesRecorded || 0) > 0;
+ const audioEmptyDespiteIntent =
+ audioDiag &&
+ audioDiag.micChosen === true &&
+ audioDiag.chunksOut === 0 &&
+ otherTrackRecorded;
const suspectedFailed =
status !== "completed" ||
(screenDiag && screenDiag.chunksOut === 0) ||
- (cameraDiag && cameraDiag.chunksOut === 0);
+ (cameraDiag && cameraDiag.chunksOut === 0) ||
+ audioEmptyDespiteIntent;
const eventType = suspectedFailed
? "recording_failed_bundle"
: "recording_stop_diag";
@@ -1816,6 +1951,7 @@ const CloudRecorder = () => {
status,
screenDiag,
cameraDiag,
+ audioDiag,
lifecycleBundle,
});
}
@@ -3314,7 +3450,21 @@ const CloudRecorder = () => {
}
};
- const createMediaRecorder = (stream, options, onDataAvailable) => {
+ // The codec to drop to when an encoder passes isTypeSupported() but
+ // fails at runtime (EncodingError). Returns null when there's nothing
+ // safer left to try (already on VP8/webm), in which case we surface the
+ // error instead of looping.
+ const pickEncodingFallback = (currentMime, trackKind) => {
+ const m = String(currentMime || "").toLowerCase();
+ if (trackKind === "audio" || m.startsWith("audio/")) {
+ // Opus-in-webm is the floor for audio; nothing safer to fall to.
+ return null;
+ }
+ if (m.includes("vp8") || m === "video/webm") return null;
+ return "video/webm;codecs=vp8,opus";
+ };
+
+ const createMediaRecorder = (stream, options, onDataAvailable, trackKind) => {
try {
// Pro hardcodes one mimeType per track. On Linux with some GPU
// drivers + WebCodecs sticky-disabled, construct throws with no
@@ -3355,6 +3505,11 @@ const CloudRecorder = () => {
recorder.ondataavailable = (event) => {
if (event.data && event.data.size > 0) {
+ // Marks the recorder as having produced bytes. The EncodingError
+ // auto-retry below only fires when NO data was captured yet, so a
+ // mid-session encoder failure isn't silently restarted (which
+ // would drop already-recorded media).
+ recorder._gotData = true;
try {
const maybePromise = onDataAvailable(event.data);
if (maybePromise && typeof maybePromise.then === "function") {
@@ -3388,6 +3543,80 @@ const CloudRecorder = () => {
});
return;
}
+
+ // EncodingError: the encoder passed isTypeSupported() at construction
+ // but failed once real frames arrived (known on older Android H.264
+ // and high-res getDisplayMedia encoder init). Chrome surfaces it as
+ // EncodingError or one of these messages. If no bytes were captured
+ // yet, transparently rebuild on VP8 and restart on the same stream —
+ // nothing was recorded or uploaded, so the swap loses nothing and the
+ // user barely notices. If data already flowed, we do NOT restart
+ // (that would discard it); we fall through to the normal surface +
+ // graceful stop, keeping what was recorded.
+ const isEncodingError =
+ errName === "EncodingError" ||
+ errMsg.includes("video encoding failed") ||
+ errMsg.includes("encoder initialization failed") ||
+ errMsg.includes("not supported by the encoder");
+ const refForTrack =
+ trackKind === "audio"
+ ? audioRecorder
+ : trackKind === "camera"
+ ? cameraRecorder
+ : trackKind === "screen"
+ ? screenRecorder
+ : null;
+ if (
+ isEncodingError &&
+ !recorder._fellBack &&
+ !recorder._gotData &&
+ refForTrack
+ ) {
+ const fallbackMime = pickEncodingFallback(
+ effectiveOptions?.mimeType,
+ trackKind,
+ );
+ if (fallbackMime && MediaRecorder.isTypeSupported(fallbackMime)) {
+ recorder._fellBack = true;
+ logDebugEvent("encoding-error-fallback", {
+ trackKind,
+ from: effectiveOptions?.mimeType || null,
+ to: fallbackMime,
+ message: event?.error?.message || null,
+ });
+ // Tear down the dead recorder without letting its stop fire the
+ // normal onstop/finalize path.
+ try {
+ recorder.ondataavailable = null;
+ recorder.onstop = null;
+ if (recorder.state !== "inactive") recorder.stop();
+ } catch {}
+ try {
+ const replacement = createMediaRecorder(
+ stream,
+ { ...effectiveOptions, mimeType: fallbackMime },
+ onDataAvailable,
+ trackKind,
+ );
+ // One downgrade only; if VP8 also fails it surfaces normally.
+ replacement._fellBack = true;
+ // Only adopt if the ref still points at the dead recorder; a
+ // concurrent teardown may have already moved on.
+ if (refForTrack.current === recorder) {
+ refForTrack.current = replacement;
+ replacement.start(2000); // matches the 2000ms timeslice at the start sites
+ return;
+ }
+ } catch (retryErr) {
+ console.error(
+ "[CloudRecorder] EncodingError VP8 retry failed:",
+ retryErr,
+ );
+ // fall through to surface the original error
+ }
+ }
+ }
+
console.error("MediaRecorder error:", event.error);
sendRecordingError("Recording error: " + event.error?.message);
};
@@ -4418,11 +4647,13 @@ const CloudRecorder = () => {
useEffect(() => {
const onVisibilityChange = () => {
if (document.visibilityState === "hidden") {
+ logForensicEvent("visibility-hidden");
persistSessionState({
visibilityState: "hidden",
visibilityChangedAt: Date.now(),
});
} else if (document.visibilityState === "visible") {
+ logForensicEvent("visibility-visible");
// In-tab heartbeat may have been throttled while hidden; force stall-recovery.
try {
const now = Date.now();
@@ -4468,6 +4699,31 @@ const CloudRecorder = () => {
};
}, []);
+ // Focus/lifecycle timeline (recorder is a pinned tab): window blur/focus and
+ // page freeze/resume, to correlate a freeze with the user switching away.
+ useEffect(() => {
+ if (IS_OFFSCREEN_HOST) return undefined;
+ const onWindowBlur = () => logForensicEvent("window-blur");
+ const onWindowFocus = () => logForensicEvent("window-focus");
+ const onPageFreeze = () => logForensicEvent("page-freeze");
+ const onPageResume = () => logForensicEvent("page-resume");
+ const onPageShow = () => logForensicEvent("pageshow");
+
+ window.addEventListener("blur", onWindowBlur);
+ window.addEventListener("focus", onWindowFocus);
+ document.addEventListener("freeze", onPageFreeze);
+ document.addEventListener("resume", onPageResume);
+ window.addEventListener("pageshow", onPageShow);
+
+ return () => {
+ window.removeEventListener("blur", onWindowBlur);
+ window.removeEventListener("focus", onWindowFocus);
+ document.removeEventListener("freeze", onPageFreeze);
+ document.removeEventListener("resume", onPageResume);
+ window.removeEventListener("pageshow", onPageShow);
+ };
+ }, []);
+
useEffect(() => {
const onOffline = () => {
networkStateRef.current = {
@@ -4563,10 +4819,11 @@ 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.
+ // 30s heartbeat snapshots track counters mid-recording so a session
+ // that dies before stop (tab kill, sleep, crash) still leaves
+ // breadcrumbs at the server. Covers the WebCodecs screen/camera diags
+ // and the MediaRecorder audio diag, so a mic that goes silent mid-
+ // recording is visible before the final stop-diag.
useEffect(() => {
if (!started) return;
const intervalId = setInterval(() => {
@@ -4574,10 +4831,12 @@ const CloudRecorder = () => {
if (!recorderSession.current?.id) return;
const screen = screenRecorder.current?.getDiagSnapshot?.();
const camera = cameraRecorder.current?.getDiagSnapshot?.();
- if (!screen && !camera) return;
+ const audio = getAudioDiagSnapshot();
+ if (!screen && !camera && !audio) return;
void emitUploadTelemetry("recording_heartbeat", {
screenDiag: screen || null,
cameraDiag: camera || null,
+ audioDiag: audio || null,
});
} catch {}
}, 30_000);
@@ -5684,9 +5943,12 @@ const CloudRecorder = () => {
},
audio: data.systemAudio,
};
- const stream = await navigator.mediaDevices.getDisplayMedia(
+ const stream = await acquireDisplayMediaWithFocusRetry({
+ getDisplayMedia: (c) => navigator.mediaDevices.getDisplayMedia(c),
constraints,
- );
+ onReactivate: () =>
+ chrome.runtime.sendMessage({ type: "activate-recorder-tab" }),
+ });
screenStream.current = stream;
regionRef.current = true;
if (!screenStream.current?.getVideoTracks?.().length) {
@@ -5872,8 +6134,20 @@ const CloudRecorder = () => {
frameRate: { ideal: targetFps, max: targetFps },
width: { ideal: targetWidth, max: targetWidth },
height: { ideal: targetHeight, max: targetHeight },
- ...(isTabModeRequest ? { displaySurface: "browser" } : {}),
+ // Open the picker on Entire Screen for screen, Chrome Tab for
+ // tab/region. Hint only; the user can still switch panes.
+ displaySurface: isTabModeRequest ? "browser" : "monitor",
},
+ // systemAudio:"include" (default may hide the toggle);
+ // surfaceSwitching:"exclude" dodges crbug 344876285 (switch ends
+ // mac audio). Screen-only; these throw TypeError w/ preferCurrentTab.
+ ...(isTabModeRequest
+ ? {}
+ : {
+ systemAudio: "include",
+ surfaceSwitching: "exclude",
+ selfBrowserSurface: "exclude",
+ }),
};
console.log(
"[CloudRecorder] offscreen getDisplayMedia constraints",
@@ -5886,9 +6160,12 @@ const CloudRecorder = () => {
payload: displayConstraints,
})
.catch(() => {});
- screenStream.current = await navigator.mediaDevices.getDisplayMedia(
- displayConstraints,
- );
+ screenStream.current = await acquireDisplayMediaWithFocusRetry({
+ getDisplayMedia: (c) => navigator.mediaDevices.getDisplayMedia(c),
+ constraints: displayConstraints,
+ onReactivate: () =>
+ chrome.runtime.sendMessage({ type: "activate-recorder-tab" }),
+ });
console.log("[CloudRecorder] offscreen getDisplayMedia OK");
} else {
if (!id) {
@@ -6199,6 +6476,11 @@ const CloudRecorder = () => {
recordingDuration: dur,
isLikelyContinuityMic,
salvageOffered: !isShort,
+ audioContextState: aCtx.current?.state ?? null,
+ docVisibility:
+ typeof document !== "undefined"
+ ? document.visibilityState
+ : null,
},
});
} catch {}
@@ -6226,7 +6508,10 @@ const CloudRecorder = () => {
// Some platforms reject hint sampleRates; fall back to default.
aCtx.current = new AudioContext();
}
- attachAudioContextWatchdog(aCtx.current, "CloudRecorder");
+ audioHealthRef.current = attachAudioContextWatchdog(
+ aCtx.current,
+ "CloudRecorder",
+ );
destination.current = aCtx.current.createMediaStreamDestination();
if (micStream.current?.getAudioTracks().length) {
@@ -6252,6 +6537,27 @@ const CloudRecorder = () => {
.connect(audioOutputGain.current)
.connect(destination.current);
+ // Diagnostic only: system/tab audio can die mid-recording (tab closed,
+ // OS mute, BT disconnect). Log it, don't stop; video/mic continue.
+ const screenAudioTrack = screenStream.current.getAudioTracks()[0];
+ if (screenAudioTrack) {
+ screenAudioTrack.addEventListener("ended", () => {
+ if (isFinishing.current) return;
+ // No track label / identifiers: diagnostics stay free of titles,
+ // names, and anything beyond the account ID.
+ const info = { reason: "system-audio-track-ended" };
+ console.warn("[CloudRecorder] system audio track ended");
+ try {
+ chrome.runtime.sendMessage({
+ type: "diag-forward",
+ event: "cloudrecorder-system-audio-track-ended",
+ data: info,
+ });
+ } catch {}
+ chrome.storage.local.set({ lastTrackEndEvent: info });
+ });
+ }
+
const { systemAudioVolume } = await chrome.storage.local.get([
"systemAudioVolume",
]);
@@ -6375,6 +6681,18 @@ const CloudRecorder = () => {
navigator.permissions.query({ name: "microphone" }),
]);
+ // macOS + Chrome 141+ routes screen capture through getDisplayMedia for
+ // system audio. See screenCaptureMode.js.
+ const { forceDisplayMediaScreen, macSystemAudioCapture } =
+ await chrome.storage.local.get([
+ "forceDisplayMediaScreen",
+ "macSystemAudioCapture",
+ ]);
+ const screenDisplayMediaMode = shouldUseDisplayMediaForScreen({
+ forceDisplayMediaScreen,
+ macSystemAudioCapture,
+ });
+
if (isTab.current) {
// Wait for getStreamID across all recordingTypes: an earlier guard skipped
// region tab-captures and started with tabID.current = null.
@@ -6437,10 +6755,18 @@ const CloudRecorder = () => {
!(IS_IFRAME_CONTEXT && regionRef.current) &&
(data.recordingType != "region" || tabPreferred.current)
) {
- _diagBranch("desktop-picker");
- // Desktop picker path: non-tab mode without region, or tabPreferred forced
- // isTab=false (playground) so there's no pre-obtained streamId.
- {
+ if (screenDisplayMediaMode) {
+ // getDisplayMedia path; startStream's useDisplayMedia branch handles it.
+ _diagBranch("screen-getDisplayMedia");
+ chrome.storage.local.set({ lastScreenCaptureApi: "getDisplayMedia" });
+ startStream(data, null, permissions, permissions2, {
+ useDisplayMedia: true,
+ });
+ } else {
+ _diagBranch("desktop-picker");
+ 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.
chrome.desktopCapture.chooseDesktopMedia(
["screen", "window", "tab", "audio"],
null,
diff --git a/src/pages/CloudRecorder/encoder/chooseEncoder.js b/src/pages/CloudRecorder/encoder/chooseEncoder.js
index 632fe01..73c9ea3 100644
--- a/src/pages/CloudRecorder/encoder/chooseEncoder.js
+++ b/src/pages/CloudRecorder/encoder/chooseEncoder.js
@@ -165,7 +165,7 @@ export const chooseTrackEncoder = async ({
if (plan.kind === "mediarecorder") {
return {
...plan,
- recorder: createMediaRecorder(stream, { mimeType }, onDataAvailable),
+ recorder: createMediaRecorder(stream, { mimeType }, onDataAvailable, track),
};
}
diff --git a/src/pages/CloudRecorder/warning/Warning.jsx b/src/pages/CloudRecorder/warning/Warning.jsx
index 29c7a0d..3699c77 100644
--- a/src/pages/CloudRecorder/warning/Warning.jsx
+++ b/src/pages/CloudRecorder/warning/Warning.jsx
@@ -10,6 +10,8 @@ import { ReactSVG } from "react-svg";
import * as ToastEl from "@radix-ui/react-toast";
+import { shouldUseDisplayMediaForScreen } from "../../utils/screenCaptureMode";
+
const Warning = () => {
const [open, setOpen] = useState(false);
const [title, setTitle] = useState("Record computer audio");
@@ -24,21 +26,32 @@ const Warning = () => {
}, []);
useEffect(() => {
- // Check if macOS
+ // macOS + Chrome 141+ captures system audio via getDisplayMedia, so show
+ // Windows-style guidance. Read the same flags the capture path uses so the
+ // warning can't disagree with what actually happens.
const isMac = navigator.userAgent.indexOf("Mac") !== -1;
- if (isMac) {
- openWarning(
- chrome.i18n.getMessage("recordAudioWarningMacTitle"),
- chrome.i18n.getMessage("recordAudioWarningMacDescription"),
- 10000
- );
- } else {
- openWarning(
- chrome.i18n.getMessage("recordAudioWarningOtherTitle"),
- chrome.i18n.getMessage("recordAudioWarningOtherDescription"),
- 10000
- );
- }
+ chrome.storage.local.get(
+ ["forceDisplayMediaScreen", "macSystemAudioCapture"],
+ ({ forceDisplayMediaScreen, macSystemAudioCapture }) => {
+ const useDisplayMedia = shouldUseDisplayMediaForScreen({
+ forceDisplayMediaScreen,
+ macSystemAudioCapture,
+ });
+ if (isMac && !useDisplayMedia) {
+ openWarning(
+ chrome.i18n.getMessage("recordAudioWarningMacTitle"),
+ chrome.i18n.getMessage("recordAudioWarningMacDescription"),
+ 10000
+ );
+ } else {
+ openWarning(
+ chrome.i18n.getMessage("recordAudioWarningOtherTitle"),
+ chrome.i18n.getMessage("recordAudioWarningOtherDescription"),
+ 10000
+ );
+ }
+ }
+ );
}, []);
return (
diff --git a/src/pages/Content/context/ContentState.jsx b/src/pages/Content/context/ContentState.jsx
index 247ce11..3c824cc 100644
--- a/src/pages/Content/context/ContentState.jsx
+++ b/src/pages/Content/context/ContentState.jsx
@@ -48,10 +48,10 @@ const ContentState = (props) => {
const CLOUD_FEATURES_ENABLED =
process.env.SCREENITY_ENABLE_CLOUD_FEATURES === "true";
setTimer = setTimerInternal;
- const [URL, setURL] = useState(
+ const [URL] = useState(
"https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/why-does-screenity-ask-for-permissions/9AAE8zJ6iiUtCAtjn4SUT1",
);
- const [URL2, setURL2] = useState(
+ const [URL2] = useState(
"https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/how-to-grant-screenity-permission-to-record-your-camera-and-microphone/x6U69TnrbMjy5CQ96Er2E9",
);
const startBeepRef = useRef(null);
@@ -97,7 +97,11 @@ const ContentState = (props) => {
const verifyUser = useCallback(async () => {
if (!CLOUD_FEATURES_ENABLED) return;
- const result = await checkAuthStatus();
+ // Don't force a cookie-based re-login from the popup: a fresh install with
+ // no prior signals stays logged out (shows the welcome immediately) until
+ // the user explicitly clicks "Log in". Returning users still auto-verify
+ // via hasPriorSignals in loginWithWebsite.
+ const result = await checkAuthStatus({ force: false });
setContentState((prev) => ({
...prev,
@@ -170,22 +174,6 @@ const ContentState = (props) => {
} catch {}
}, []);
- useEffect(() => {
- const locale = chrome.i18n.getMessage("@@ui_locale");
- if (!locale.includes("en")) {
- setURL(
- "https://translate.google.com/translate?sl=en&tl=" +
- locale +
- "&u=https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/why-does-screenity-ask-for-permissions/9AAE8zJ6iiUtCAtjn4SUT1",
- );
- setURL2(
- "https://translate.google.com/translate?sl=en&tl=" +
- locale +
- "&u=https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/how-to-grant-screenity-permission-to-record-your-camera-and-microphone/x6U69TnrbMjy5CQ96Er2E9",
- );
- }
- }, []);
-
const startRecording = useCallback(() => {
const shouldClearCountdown =
!contentStateRef.current?.isCountdownVisible &&
@@ -690,17 +678,9 @@ const ContentState = (props) => {
if (typeof contentStateRef.current.openModal === "function") {
let clear = null;
let clearAction = () => {};
- const locale = chrome.i18n.getMessage("@@ui_locale");
- let helpURL =
+ const helpURL =
"https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/what-does-%E2%80%9Cmemory-limit-reached%E2%80%9D-mean-when-recording/8WkwHbt3puuXunYqQnyPcb";
- if (!locale.includes("en")) {
- helpURL =
- "https://translate.google.com/translate?sl=en&tl=" +
- locale +
- "&u=https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/what-does-%E2%80%9Cmemory-limit-reached%E2%80%9D-mean-when-recording/8WkwHbt3puuXunYqQnyPcb";
- }
-
const response = await chrome.runtime.sendMessage({
type: "check-restore",
});
diff --git a/src/pages/Content/context/utils/checkAuthStatus.js b/src/pages/Content/context/utils/checkAuthStatus.js
index f5976a3..5edcd0f 100644
--- a/src/pages/Content/context/utils/checkAuthStatus.js
+++ b/src/pages/Content/context/utils/checkAuthStatus.js
@@ -1,21 +1,24 @@
-export const checkAuthStatus = async () => {
+export const checkAuthStatus = async ({ force = true } = {}) => {
return new Promise((resolve) => {
- chrome.runtime.sendMessage({ type: "check-auth-status" }, (response) => {
- if (chrome.runtime.lastError) {
- console.error(
- "❌ Error checking auth status:",
- chrome.runtime.lastError.message
- );
- resolve({ authenticated: false });
- } else {
- resolve({
- authenticated: !!response?.authenticated,
- user: response?.user ?? null,
- subscribed: !!response?.subscribed,
- proSubscription: response?.proSubscription ?? null,
- cached: response?.cached ?? false,
- });
+ chrome.runtime.sendMessage(
+ { type: "check-auth-status", force },
+ (response) => {
+ if (chrome.runtime.lastError) {
+ console.error(
+ "❌ Error checking auth status:",
+ chrome.runtime.lastError.message
+ );
+ resolve({ authenticated: false });
+ } else {
+ resolve({
+ authenticated: !!response?.authenticated,
+ user: response?.user ?? null,
+ subscribed: !!response?.subscribed,
+ proSubscription: response?.proSubscription ?? null,
+ cached: response?.cached ?? false,
+ });
+ }
}
- });
+ );
});
};
diff --git a/src/pages/Content/popup/PopupContainer.jsx b/src/pages/Content/popup/PopupContainer.jsx
index 77980a8..348ebdb 100644
--- a/src/pages/Content/popup/PopupContainer.jsx
+++ b/src/pages/Content/popup/PopupContainer.jsx
@@ -89,8 +89,6 @@ const PopupContainer = (props) => {
useEffect(() => {
const buildURL = async () => {
- const locale = chrome.i18n.getMessage("@@ui_locale");
-
let baseURL = "https://help.screenity.io/";
if (contentState?.isLoggedIn && contentState?.screenityUser) {
@@ -103,15 +101,7 @@ const PopupContainer = (props) => {
baseURL = `https://tally.so/r/310MNg?extension=true&${qs}`;
}
- if (!locale.includes("en")) {
- setURL(
- `https://translate.google.com/translate?sl=en&tl=${locale}&u=${encodeURIComponent(
- baseURL
- )}`
- );
- } else {
- setURL(baseURL);
- }
+ setURL(baseURL);
};
buildURL();
}, [contentState]);
@@ -157,16 +147,32 @@ const PopupContainer = (props) => {
tab,
]);
+ const previewWelcome = (() => {
+ try {
+ return (
+ new URLSearchParams(window.location.search).get("previewWelcome") ===
+ "1"
+ );
+ } catch {
+ return false;
+ }
+ })();
+
const showWelcomeSplash = Boolean(
- isCloudBuild &&
- !contentState.isLoggedIn &&
+ (isCloudBuild &&
+ // Strict === false (not just falsy) so the splash stays hidden while the
+ // auth check is still in flight. Otherwise a reinstalled user who gets
+ // silently re-logged-in via their website cookie would briefly flash the
+ // paid welcome screen before isLoggedIn resolves to true.
+ contentState.isLoggedIn === false &&
!contentState.wasLoggedIn &&
(
onboarding ||
showProSplash ||
contentState.onboarding ||
contentState.showProSplash
- ),
+ )) ||
+ (isCloudBuild && previewWelcome),
);
useLayoutEffect(() => {
diff --git a/src/pages/Content/popup/layout/Announcement.jsx b/src/pages/Content/popup/layout/Announcement.jsx
index df65db1..daea49f 100644
--- a/src/pages/Content/popup/layout/Announcement.jsx
+++ b/src/pages/Content/popup/layout/Announcement.jsx
@@ -1,22 +1,9 @@
-import React, { useState, useEffect } from "react";
+import React from "react";
const Announcement = (props) => {
- const [URL, setURL] = useState(
- "https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what%E2%80%99s-changed-in-the-new-version-of-screenity/bDtvcwAtw9PPesQeNH4zjE"
- );
+ const URL =
+ "https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what%E2%80%99s-changed-in-the-new-version-of-screenity/bDtvcwAtw9PPesQeNH4zjE";
- useEffect(() => {
- // check i18n locale, and set URL accordingly w/ google translate
- const locale = chrome.i18n.getMessage("@@ui_locale");
- if (!locale.includes("en")) {
- setURL(
- "https://translate.google.com/translate?sl=en&tl=" +
- locale +
- "&u=" +
- URL
- );
- }
- }, []);
return (
<div className="welcome">
<div className="announcement-wrap">
diff --git a/src/pages/Content/popup/layout/RecordingType.jsx b/src/pages/Content/popup/layout/RecordingType.jsx
index 5eca760..84b99a6 100644
--- a/src/pages/Content/popup/layout/RecordingType.jsx
+++ b/src/pages/Content/popup/layout/RecordingType.jsx
@@ -19,10 +19,10 @@ const RecordingType = (props) => {
const [contentState, setContentState] = useContext(contentStateContext);
const [cropActive, setCropActive] = useState(false);
const [time, setTime] = useState(0);
- const [URL, setURL] = useState(
+ const [URL] = useState(
"https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what-are-the-technical-requirements-for-using-screenity/6kdB6qru6naVD8ZLFvX3m9"
);
- const [URL2, setURL2] = useState(
+ const [URL2] = useState(
"https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/how-to-grant-screenity-permission-to-record-your-camera-and-microphone/x6U69TnrbMjy5CQ96Er2E9"
);
@@ -71,18 +71,6 @@ const RecordingType = (props) => {
);
};
- useEffect(() => {
- const locale = chrome.i18n.getMessage("@@ui_locale");
- if (!locale.includes("en")) {
- setURL(
- `https://translate.google.com/translate?sl=en&tl=${locale}&u=https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what-are-the-technical-requirements-for-using-screenity/6kdB6qru6naVD8ZLFvX3m9`
- );
- setURL2(
- `https://translate.google.com/translate?sl=en&tl=${locale}&u=https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/how-to-grant-screenity-permission-to-record-your-camera-and-microphone/x6U69TnrbMjy5CQ96Er2E9`
- );
- }
- }, []);
-
useEffect(() => {
// Convert seconds to mm:ss
let minutes = Math.floor(contentState.alarmTime / 60);
diff --git a/src/pages/Content/popup/layout/Welcome.jsx b/src/pages/Content/popup/layout/Welcome.jsx
index 7b9b3e3..5709115 100644
--- a/src/pages/Content/popup/layout/Welcome.jsx
+++ b/src/pages/Content/popup/layout/Welcome.jsx
@@ -1,19 +1,9 @@
-import React, { useEffect, useState } from "react";
-import SoloDev from "../../../../assets/solo-dev.png";
+import React from "react";
// import EditorPreview from "../../../../assets/editor-preview.png"; // replace with actual screenshot file
const Welcome = (props) => {
const isUpdated = props.isBack;
const clearBack = props.clearBack;
- const [learntAboutPro, setLearntAboutPro] = useState(false);
-
- useEffect(() => {
- // if (isUpdated) {
- chrome.storage.local.get("learntAboutPro", (res) => {
- if (res.learntAboutPro) setLearntAboutPro(true);
- });
- // }
- }, []);
return (
<div
@@ -96,22 +86,13 @@ const Welcome = (props) => {
textAlign: "center",
}}
>
- {learntAboutPro
- ? chrome.i18n.getMessage("welcomeProDescription") ||
- "Sign in to save your videos to the cloud, share with a link, and access advanced editing features."
- : chrome.i18n.getMessage("welcomeBackProDescription") ||
- "Sign in to save your videos to the cloud, share with a link, and access advanced editing features."}
+ {chrome.i18n.getMessage("welcomeProDescription") ||
+ "Cloud backup, real editing, and a clean link to share."}
</p>
- {/* <div
+ <div
onClick={() => {
- if (!isUpdated || learntAboutPro) {
- chrome.runtime.sendMessage({ type: "handle-login" });
- } else {
- chrome.storage.local.set({ learntAboutPro: true });
- chrome.runtime.sendMessage({ type: "pricing" });
- setLearntAboutPro(true);
- }
+ chrome.runtime.sendMessage({ type: "pricing", source: "welcome" });
}}
role="button"
className="main-button dashboard-button"
@@ -122,58 +103,36 @@ const Welcome = (props) => {
}}
>
<span className="main-button-label">
- {!isUpdated || learntAboutPro
- ? chrome.i18n.getMessage("welcomeProButton") ||
- "Sign in to unlock paid features"
- : !learntAboutPro
- ? chrome.i18n.getMessage("welcomeBackProCTA") ||
- "Learn more about Screenity Pro"
- : chrome.i18n.getMessage("welcomeBackProCTAAfterLearn") ||
- "Sign in to unlock paid features"}
+ {chrome.i18n.getMessage("welcomeProButton") || "Unlock the editor"}
</span>
- </div> */}
-
+ <span
+ className="main-button-label"
+ style={{
+ opacity: 0.55,
+ fontWeight: 400,
+ marginLeft: "8px",
+ }}
+ >
+ $10/mo
+ </span>
+ </div>
<div
onClick={() => {
- if (learntAboutPro) {
- // After they've seen the Pro info, trigger sign in
- chrome.runtime.sendMessage({ type: "handle-login" });
- } else {
- // First click: show pricing page and mark as "learnt"
- chrome.storage.local.set({ learntAboutPro: true });
- chrome.runtime.sendMessage({ type: "pricing" });
- setLearntAboutPro(true);
- }
+ chrome.runtime.sendMessage({ type: "handle-login" });
}}
role="button"
- className="main-button dashboard-button"
tabIndex="0"
style={{
- zIndex: 99,
- marginTop: "25px",
- }}
- >
- <span className="main-button-label">
- {learntAboutPro
- ? chrome.i18n.getMessage("welcomeProButton") ||
- "Sign in to unlock paid features"
- : chrome.i18n.getMessage("welcomeBackProCTA") ||
- "Learn more about Screenity Pro"}
- </span>
- </div>
- <a
- className="welcome-support"
- href="https://alyssax.substack.com/"
- target="_blank"
- rel="noopener noreferrer"
- style={{
+ marginTop: "14px",
+ fontSize: "13px",
+ color: "#6E7684",
cursor: "pointer",
+ textAlign: "center",
}}
>
- {chrome.i18n.getMessage("welcomeProSupport") ||
- "Support development by a solo indie maker "}
- <img src={chrome.runtime.getURL(SoloDev)} alt="Alyssa X" />
- </a>
+ {chrome.i18n.getMessage("shareModalSandboxLogin") ||
+ "Already have an account? Log in"}
+ </div>
</div>
</div>
</div>
diff --git a/src/pages/Editor/Sandbox.jsx b/src/pages/Editor/Sandbox.jsx
index c866aa2..9efc94a 100644
--- a/src/pages/Editor/Sandbox.jsx
+++ b/src/pages/Editor/Sandbox.jsx
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from "react";
import addAudioToVideo from "./utils/addAudioToVideo";
import base64ToBlob from "./utils/base64toBlob";
+import { fixWebmDurationOffThread } from "./utils/fixWebmDurationOffThread";
import blobToArrayBuffer from "./utils/blobToArrayBuffer";
import cropVideo from "./utils/cropVideo";
import cutVideo from "./utils/cutVideo";
@@ -86,6 +87,26 @@ const Sandbox = () => {
if (message.type === "load-ffmpeg") {
triggerLoad.current = true;
loadFfmpeg();
+ } else if (message.type === "fix-webm-duration") {
+ // The child iframe can't spawn a blob worker (extension_pages CSP), so it
+ // relays the Blob up here, where the sandbox CSP allows it.
+ try {
+ const fixed = await fixWebmDurationOffThread(
+ message.blob,
+ message.durationMs,
+ );
+ sendMessage({
+ type: "fix-webm-duration-result",
+ id: message.id,
+ blob: fixed,
+ });
+ } catch (error) {
+ sendMessage({
+ type: "fix-webm-duration-result",
+ id: message.id,
+ error: String(error),
+ });
+ }
} else if (message.type === "add-audio-to-video") {
try {
const blob = await addAudioToVideo(
diff --git a/src/pages/Editor/utils/fixWebmDurationOffThread.js b/src/pages/Editor/utils/fixWebmDurationOffThread.js
new file mode 100644
index 0000000..2aba751
--- /dev/null
+++ b/src/pages/Editor/utils/fixWebmDurationOffThread.js
@@ -0,0 +1,83 @@
+// Off-main-thread fix-webm-duration via a blob-URL worker, so the EBML rewrite
+// doesn't freeze the renderer. Must run in editor.html (only its sandbox CSP
+// allows blob workers). Falls back to the synchronous path on any failure.
+import webmDurationLibSrc from "!!raw-loader!fix-webm-duration/fix-webm-duration.js";
+import fixWebmDurationSync from "fix-webm-duration";
+
+let cachedWorkerUrl = null;
+
+const getWorkerUrl = () => {
+ if (cachedWorkerUrl) return cachedWorkerUrl;
+ // Shim window so the lib's UMD assigns self.ysFixWebmDuration in the worker.
+ const src =
+ "var window = self;\n" +
+ webmDurationLibSrc +
+ "\nself.onmessage = function (e) {\n" +
+ " var d = e.data || {};\n" +
+ " try {\n" +
+ " self.ysFixWebmDuration(d.blob, d.durationMs, function (fixed) {\n" +
+ " self.postMessage({ ok: true, blob: fixed });\n" +
+ " }, { logger: false });\n" +
+ " } catch (err) {\n" +
+ " self.postMessage({ ok: false, error: String((err && err.message) || err) });\n" +
+ " }\n" +
+ "};\n";
+ cachedWorkerUrl = URL.createObjectURL(
+ new Blob([src], { type: "application/javascript" }),
+ );
+ return cachedWorkerUrl;
+};
+
+// Resolves to a duration-fixed Blob. Off the main thread when possible.
+export const fixWebmDurationOffThread = (blob, durationMs) =>
+ new Promise((resolve) => {
+ let done = false;
+ let worker = null;
+ let timer = null;
+
+ function cleanup() {
+ if (timer) clearTimeout(timer);
+ if (worker) {
+ try {
+ worker.terminate();
+ } catch (e) {}
+ }
+ }
+ const finishSync = () => {
+ if (done) return;
+ done = true;
+ cleanup();
+ try {
+ fixWebmDurationSync(blob, durationMs, (f) => resolve(f), {
+ logger: false,
+ });
+ } catch (e) {
+ resolve(blob); // unfixed (plays from start; seek metadata may be off)
+ }
+ };
+ const finishOk = (fixed) => {
+ if (done) return;
+ done = true;
+ cleanup();
+ resolve(fixed);
+ };
+
+ try {
+ worker = new Worker(getWorkerUrl());
+ } catch (e) {
+ finishSync();
+ return;
+ }
+ timer = setTimeout(finishSync, 90000);
+ worker.onmessage = (e) => {
+ const d = e.data || {};
+ if (d.ok && d.blob) finishOk(d.blob);
+ else finishSync();
+ };
+ worker.onerror = () => finishSync();
+ try {
+ worker.postMessage({ blob, durationMs });
+ } catch (e) {
+ finishSync();
+ }
+ });
diff --git a/src/pages/Recorder/Recorder.jsx b/src/pages/Recorder/Recorder.jsx
index fb1f54c..3f37c10 100644
--- a/src/pages/Recorder/Recorder.jsx
+++ b/src/pages/Recorder/Recorder.jsx
@@ -17,6 +17,8 @@ import { getUserMediaWithFallback } from "../utils/mediaDeviceFallback";
import { shouldAcquireMicAtStart } from "../utils/micAcquisitionPolicy";
import { attachAudioContextWatchdog } from "../utils/audioContextWatchdog";
import { IS_OFFSCREEN_HOST } from "../utils/recordingHost";
+import { shouldUseDisplayMediaForScreen } from "../utils/screenCaptureMode";
+import { acquireDisplayMediaWithFocusRetry } from "../utils/acquireDisplayMedia";
import { chooseWriter } from "./recorderStorage/chooseWriter";
import { chooseReader } from "./recorderStorage/chooseReader";
import { lifecycle } from "../utils/lifecycleLog";
@@ -2044,7 +2046,6 @@ const Recorder = () => {
if (validation && !validation.ok) {
await markFastRecorderFailure("validation-failed", validation);
await chrome.storage.local.set({
- useWebCodecsRecorder: false,
lastWebCodecsFailureAt: Date.now(),
lastWebCodecsFailureCode: "validation-failed",
lastFailedValidation: {
@@ -2131,7 +2132,8 @@ const Recorder = () => {
: failureCode,
lastWebCodecsFailureDetail: err?.detail || null,
};
- if (!transient) persisted.useWebCodecsRecorder = false;
+ // Disable is via markFastRecorderFailure above (recoverable sticky
+ // with TTL); don't pin the durable useWebCodecsRecorder user setting.
chrome.storage.local.set(persisted);
if (fatalFinalized) return;
updateFreeFinalizeStatus("failed", 100, errStr);
@@ -2237,8 +2239,9 @@ const Recorder = () => {
);
useWebCodecs.current = false;
await chrome.storage.local.set({ fastRecorderInUse: false });
+ // Recoverable device-sticky disable, not the durable user setting.
+ await markFastRecorderFailure("start-failed", {});
await chrome.storage.local.set({
- useWebCodecsRecorder: false,
lastWebCodecsFailureAt: Date.now(),
lastWebCodecsFailureCode: "start-failed",
});
@@ -2523,8 +2526,9 @@ const Recorder = () => {
} catch (err) {
debugError("startRecording() top-level error", err);
if (useWebCodecs.current) {
+ // Recoverable device-sticky disable, not the durable user setting.
+ await markFastRecorderFailure("start-exception", { error: String(err) });
await chrome.storage.local.set({
- useWebCodecsRecorder: false,
lastWebCodecsFailureAt: Date.now(),
lastWebCodecsFailureCode: "start-exception",
});
@@ -3410,7 +3414,8 @@ const Recorder = () => {
}
};
- async function startStream(data, id, options, permissions, permissions2) {
+ async function startStream(data, id, options, permissions, permissions2, streamOpts = {}) {
+ const useDisplayMedia = !!streamOpts.useDisplayMedia;
perfMark("Recorder startStream.enter", {
recordingType: data?.recordingType,
hasId: Boolean(id),
@@ -3610,6 +3615,66 @@ const Recorder = () => {
}
helperVideoStream.current = userStream;
slLog("helperVideoStream-assigned", { path: "camera", streamId: userStream.id });
+ } else if (useDisplayMedia) {
+ // macOS + Chrome 141+ screen path: getDisplayMedia for system audio.
+ // Falls through to the shared mixing/recorder setup below.
+ const displayConstraints = {
+ audio: data.systemAudio ? true : false,
+ video: {
+ frameRate: { ideal: fps, max: fps },
+ width: { ideal: width, max: width },
+ height: { ideal: height, max: height },
+ displaySurface: "monitor",
+ },
+ // systemAudio:"include" (default may hide the toggle);
+ // surfaceSwitching:"exclude" dodges crbug 344876285 (switch ends mac
+ // audio). Screen-only; these throw TypeError w/ preferCurrentTab.
+ systemAudio: "include",
+ surfaceSwitching: "exclude",
+ selfBrowserSurface: "exclude",
+ };
+ debug("getDisplayMedia screen constraints", displayConstraints);
+ slLog("getDisplayMedia-start");
+ let stream;
+ const endGdm = perfSpan("Recorder getDisplayMedia(screen)");
+ try {
+ stream = await acquireDisplayMediaWithFocusRetry({
+ getDisplayMedia: (c) => navigator.mediaDevices.getDisplayMedia(c),
+ constraints: displayConstraints,
+ onReactivate: () =>
+ chrome.runtime.sendMessage({ type: "activate-recorder-tab" }),
+ });
+ endGdm({
+ videoTracks: stream.getVideoTracks().length,
+ audioTracks: stream.getAudioTracks().length,
+ });
+ } catch (err) {
+ endGdm({ error: String(err?.message || err).slice(0, 80) });
+ const cancelled =
+ err?.name === "NotAllowedError" ||
+ err?.name === "AbortError" ||
+ String(err?.message || "").toLowerCase().includes("permission denied");
+ debugWarn("getDisplayMedia screen capture failed", err);
+ resetGateState();
+ sendRecordingError(
+ cancelled
+ ? "User cancelled the modal"
+ : "Failed to get user media: " + String(err),
+ cancelled,
+ );
+ return;
+ }
+ if (stream.getVideoTracks().length === 0) {
+ debugError("No video tracks returned from getDisplayMedia");
+ resetGateState();
+ sendRecordingError("No video tracks available");
+ return;
+ }
+ helperVideoStream.current = stream;
+ slLog("helperVideoStream-assigned", {
+ path: "getDisplayMedia",
+ streamId: stream.id,
+ });
} else {
// Chrome's tab capture defaults to a 1920x1080 frame and pillarboxes
// narrower tabs to fit. Match the constraint box to the tab's real
@@ -3762,6 +3827,9 @@ const Recorder = () => {
reason: "system-audio-track-ended",
trackLabel: String(sysTrack.label || "").slice(0, 80),
savedChunks: savedCount.current,
+ audioContextState: aCtx.current?.state ?? null,
+ docVisibility:
+ typeof document !== "undefined" ? document.visibilityState : null,
};
console.warn("[Recorder] System audio track ended", info);
try {
@@ -3884,6 +3952,11 @@ const Recorder = () => {
?.length,
hasSystemAudio:
sysTracks.length > 0 && data.systemAudio,
+ audioContextState: aCtx.current?.state ?? null,
+ docVisibility:
+ typeof document !== "undefined"
+ ? document.visibilityState
+ : null,
},
});
} catch {}
@@ -4005,6 +4078,18 @@ const Recorder = () => {
microphone: permissions2.state,
});
+ // macOS + Chrome 141+ routes screen capture through getDisplayMedia for
+ // system audio. See utils/screenCaptureMode.js.
+ const { forceDisplayMediaScreen, macSystemAudioCapture } =
+ await chrome.storage.local.get([
+ "forceDisplayMediaScreen",
+ "macSystemAudioCapture",
+ ]);
+ const screenDisplayMediaMode = shouldUseDisplayMediaForScreen({
+ forceDisplayMediaScreen,
+ macSystemAudioCapture,
+ });
+
try {
if (data.recordingType === "camera") {
debug("Streaming camera recording");
@@ -4016,6 +4101,16 @@ const Recorder = () => {
!isTab.current &&
data.recordingType !== "region"
) {
+ if (screenDisplayMediaMode) {
+ debug("screen capture via getDisplayMedia (mac+141)");
+ slLog("getDisplayMedia-screen-route");
+ chrome.storage.local.set({ lastScreenCaptureApi: "getDisplayMedia" });
+ startStream(data, null, null, permissions, permissions2, {
+ useDisplayMedia: true,
+ });
+ return;
+ }
+ chrome.storage.local.set({ lastScreenCaptureApi: "desktopCapture" });
let captureTypes = ["screen", "window", "tab", "audio"];
if (tabPreferred.current) {
captureTypes = ["tab", "screen", "window", "audio"];
diff --git a/src/pages/Recorder/warning/Warning.jsx b/src/pages/Recorder/warning/Warning.jsx
index 4b578c9..6496abc 100644
--- a/src/pages/Recorder/warning/Warning.jsx
+++ b/src/pages/Recorder/warning/Warning.jsx
@@ -10,6 +10,8 @@ import { ReactSVG } from "react-svg";
import * as ToastEl from "@radix-ui/react-toast";
+import { shouldUseDisplayMediaForScreen } from "../../utils/screenCaptureMode";
+
const Warning = () => {
const [open, setOpen] = useState(false);
const [title, setTitle] = useState("Record computer audio");
@@ -24,21 +26,32 @@ const Warning = () => {
}, []);
useEffect(() => {
- // Check if macOS
+ // macOS + Chrome 141+ captures system audio via getDisplayMedia, so show
+ // Windows-style guidance. Read the same flags the capture path uses so the
+ // warning can't disagree with what actually happens.
const isMac = navigator.userAgent.indexOf("Mac") !== -1;
- if (isMac) {
- openWarning(
- chrome.i18n.getMessage("recordAudioWarningMacTitle"),
- chrome.i18n.getMessage("recordAudioWarningMacDescription"),
- 10000
- );
- } else {
- openWarning(
- chrome.i18n.getMessage("recordAudioWarningOtherTitle"),
- chrome.i18n.getMessage("recordAudioWarningOtherDescription"),
- 10000
- );
- }
+ chrome.storage.local.get(
+ ["forceDisplayMediaScreen", "macSystemAudioCapture"],
+ ({ forceDisplayMediaScreen, macSystemAudioCapture }) => {
+ const useDisplayMedia = shouldUseDisplayMediaForScreen({
+ forceDisplayMediaScreen,
+ macSystemAudioCapture,
+ });
+ if (isMac && !useDisplayMedia) {
+ openWarning(
+ chrome.i18n.getMessage("recordAudioWarningMacTitle"),
+ chrome.i18n.getMessage("recordAudioWarningMacDescription"),
+ 10000
+ );
+ } else {
+ openWarning(
+ chrome.i18n.getMessage("recordAudioWarningOtherTitle"),
+ chrome.i18n.getMessage("recordAudioWarningOtherDescription"),
+ 10000
+ );
+ }
+ }
+ );
}, []);
return (
diff --git a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
index 7df8a38..2eae2e5 100644
--- a/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
+++ b/src/pages/Recorder/webcodecs/WebCodecsRecorder.js
@@ -145,7 +145,13 @@ export class WebCodecsRecorder {
this._midStreamWatchdog = null;
this._midStreamWatchdogMs = Number.isFinite(options.midStreamWatchdogMs)
? options.midStreamWatchdogMs
- : 15000;
+ : Number.isFinite(
+ /** @type {any} */ (globalThis)
+ .__screenityMidStreamWatchdogMsForTests,
+ )
+ ? /** @type {any} */ (globalThis)
+ .__screenityMidStreamWatchdogMsForTests
+ : 15000;
// Last structured failure code that fired via _reportFailure; passed
// to onFinalized so the consumer can distinguish a clean stop, a
@@ -194,6 +200,7 @@ export class WebCodecsRecorder {
this._lastAudioReclaimRebuildAt = null;
this._encoderReclaimCount = 0;
this._audioEncoderReclaimCount = 0;
+ this._midStreamStallRebuilds = 0;
// Reset the per-encoder reclaim counter after a healthy stretch.
this._lastVideoReclaimAt = null;
this._lastAudioReclaimAt = null;
@@ -353,6 +360,7 @@ export class WebCodecsRecorder {
this._peakAudioEncodeQueueSize = 0;
this._encoderReclaimCount = 0;
this._audioEncoderReclaimCount = 0;
+ this._midStreamStallRebuilds = 0;
this._lastVideoReclaimAt = null;
this._lastAudioReclaimAt = null;
this._lastVideoReclaimRebuildAt = null;
@@ -1291,9 +1299,8 @@ export class WebCodecsRecorder {
}
}
- // Mid-stream stall watchdog. If the encoder goes silent past the
- // window (HW reclaim, hang, OS pressure), fire onError and stop the
- // loop so finalize ships what's already encoded.
+ // Mid-stream stall watchdog. On a silent stall (no error) rebuild the
+ // encoder in-session (prefer-software); give up only when budget runs out.
_armMidStreamStallWatchdog() {
this._clearMidStreamStallWatchdog();
this._lastChunkAt = performance.now();
@@ -1313,14 +1320,47 @@ export class WebCodecsRecorder {
this.warn(
`[WCR] no encoded video chunk for ${Math.round(sinceLastChunkMs)}ms mid-recording`,
);
+ // Silent stall fires no error, so the error-driven rebuild never runs.
+ // Rebuild here (prefer-software) and keep recording. Shares the budget.
+ if (
+ this.running &&
+ !this._stopping &&
+ this._activeVideoConfig &&
+ this._encoderReclaimCount < this._maxEncoderReclaims
+ ) {
+ this._encoderReclaimCount += 1;
+ this._midStreamStallRebuilds += 1;
+ this._lastVideoReclaimAt = performance.now();
+ this._lastVideoReclaimRebuildAt = performance.now();
+ this.warn("[WCR] mid-stream stall; rebuilding encoder prefer-software", {
+ attempt: this._encoderReclaimCount,
+ });
+ try {
+ diagForward("recorder-midstream-stall-rebuild", {
+ sinceLastChunkMs: Math.round(sinceLastChunkMs),
+ attempt: this._encoderReclaimCount,
+ });
+ } catch {}
+ const swConfig = {
+ ...this._activeVideoConfig,
+ hardwareAcceleration: "prefer-software",
+ };
+ if (this._rebuildVideoEncoder(swConfig)) {
+ this._didSwRetry = true;
+ this._swRetryReason = this._swRetryReason || "midstream-stall";
+ this._forceNextKeyframe = true;
+ this._lastChunkAt = performance.now();
+ return;
+ }
+ }
this._reportFailure(
"webcodecs-mid-stream-stall",
new Error(
`WebCodecs produced no chunks for ${Math.round(sinceLastChunkMs)}ms after frame ${this.frameCount}`,
),
);
- // Graceful stop: exit the run-loop so the normal finalize path
- // packages whatever was encoded into a playable file.
+ // Budget exhausted or rebuild failed: exit the run-loop so the normal
+ // finalize path packages whatever was encoded into a playable file.
this.running = false;
this._clearMidStreamStallWatchdog();
}
@@ -1367,6 +1407,11 @@ export class WebCodecsRecorder {
_g.__screenitySuppressFirstChunks -= 1;
return;
}
+ // E2E hook: drop chunks mid-stream (after the first) to simulate a
+ // silent encoder stall and drive the mid-stream rebuild path.
+ if (_g.__screenitySuppressChunks === true && this._firstChunkSeen) {
+ return;
+ }
// 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.
@@ -1506,6 +1551,7 @@ export class WebCodecsRecorder {
this._audioSampleRateMismatchRebuilds,
audioDeviceChangePending: this._audioDeviceChangePending,
postSleepRecoveries: this._postSleepRecoveries,
+ midStreamStallRebuilds: this._midStreamStallRebuilds,
firstChunkWatchdogMs: this._firstChunkWatchdogMs,
maxEncoderReclaims: this._maxEncoderReclaims,
reclaimRebuildThrottleMs: this._reclaimRebuildThrottleMs,
diff --git a/src/pages/Region/Recorder.jsx b/src/pages/Region/Recorder.jsx
index 312e0ce..6601932 100644
--- a/src/pages/Region/Recorder.jsx
+++ b/src/pages/Region/Recorder.jsx
@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useCallback } from "react";
import { getUserMediaWithFallback } from "../utils/mediaDeviceFallback";
import { shouldAcquireMicAtStart } from "../utils/micAcquisitionPolicy";
import { attachAudioContextWatchdog } from "../utils/audioContextWatchdog";
+import { acquireDisplayMediaWithFocusRetry } from "../utils/acquireDisplayMedia";
import {
startTabKeepalive,
stopTabKeepalive,
@@ -840,8 +841,9 @@ const Recorder = () => {
),
});
if (useWebCodecs.current) {
+ // Recoverable device-sticky disable, not the durable user setting.
+ await markFastRecorderFailure("start-exception", { error: String(err) });
await chrome.storage.local.set({
- useWebCodecsRecorder: false,
lastWebCodecsFailureAt: Date.now(),
lastWebCodecsFailureCode: "start-exception",
});
@@ -1231,7 +1233,6 @@ const Recorder = () => {
if (validation && !validation.ok) {
await markFastRecorderFailure("validation-failed", validation);
await chrome.storage.local.set({
- useWebCodecsRecorder: false,
lastWebCodecsFailureAt: Date.now(),
lastWebCodecsFailureCode: "validation-failed",
fastRecorderValidationFailed: Boolean(validation.hardFail),
@@ -1298,7 +1299,8 @@ const Recorder = () => {
? "webcodecs-finalized"
: "webcodecs-error",
};
- if (!transient) persisted.useWebCodecsRecorder = false;
+ // Disable is via markFastRecorderFailure above (recoverable sticky
+ // with TTL); don't pin the durable useWebCodecsRecorder user setting.
chrome.storage.local.set(persisted);
if (fatalFinalized) return;
updateFreeFinalizeStatus("failed", 100, errStr);
@@ -1415,8 +1417,9 @@ const Recorder = () => {
if (!started) {
useWebCodecs.current = false;
await chrome.storage.local.set({ fastRecorderInUse: false });
+ // Recoverable device-sticky disable, not the durable user setting.
+ await markFastRecorderFailure("start-failed", {});
await chrome.storage.local.set({
- useWebCodecsRecorder: false,
lastWebCodecsFailureAt: Date.now(),
lastWebCodecsFailureCode: "start-failed",
});
@@ -1958,6 +1961,11 @@ const Recorder = () => {
recordingDuration: dur,
isLikelyContinuityMic,
salvageOffered: !isShort,
+ audioContextState: aCtx.current?.state ?? null,
+ docVisibility:
+ typeof document !== "undefined"
+ ? document.visibilityState
+ : null,
},
});
} catch {}
@@ -2412,7 +2420,14 @@ const Recorder = () => {
},
};
const endGetDisplayMedia = perfSpan("Region.Recorder getDisplayMedia");
- stream = await navigator.mediaDevices.getDisplayMedia(constraints);
+ // Region needs a focused doc too: retry once on InvalidStateError. No
+ // monitor constraints here (tab-crop via preferCurrentTab).
+ stream = await acquireDisplayMediaWithFocusRetry({
+ getDisplayMedia: (c) => navigator.mediaDevices.getDisplayMedia(c),
+ constraints,
+ onReactivate: () =>
+ chrome.runtime.sendMessage({ type: "activate-recorder-tab" }),
+ });
endGetDisplayMedia({
videoTracks: stream?.getVideoTracks?.()?.length ?? 0,
audioTracks: stream?.getAudioTracks?.()?.length ?? 0,
diff --git a/src/pages/Sandbox/context/ContentState.jsx b/src/pages/Sandbox/context/ContentState.jsx
index 1726633..9842bf1 100644
--- a/src/pages/Sandbox/context/ContentState.jsx
+++ b/src/pages/Sandbox/context/ContentState.jsx
@@ -925,7 +925,7 @@ const ContentState = (props) => {
try {
if (safeDuration > 0) {
if (!isWindows10) {
- fixWebmDuration(
+ requestParentFixWebmDuration(
blob,
safeDuration,
async (fixedWebm) => {
@@ -2336,6 +2336,45 @@ const ContentState = (props) => {
window.parent.postMessage(message, "*");
};
+ // Off-thread the WebM duration fix by relaying the Blob to editor.html, whose
+ // CSP allows blob workers. Same shape as fix-webm-duration; sync fallback.
+ const requestParentFixWebmDuration = (blob, durationMs, callback) => {
+ let done = false;
+ let timer = null;
+ const id = "wdf-" + Date.now() + "-" + Math.random().toString(36).slice(2);
+ function finish(fixed) {
+ if (done) return;
+ done = true;
+ if (timer) clearTimeout(timer);
+ window.removeEventListener("message", onResult);
+ if (fixed) {
+ callback(fixed);
+ } else {
+ try {
+ fixWebmDuration(blob, durationMs, (f) => callback(f), {
+ logger: false,
+ });
+ } catch (err) {
+ callback(blob);
+ }
+ }
+ }
+ function onResult(e) {
+ const d = e && e.data;
+ if (!d || d.type !== "fix-webm-duration-result" || d.id !== id) return;
+ finish(d.blob || null);
+ }
+ window.addEventListener("message", onResult);
+ timer = setTimeout(function () {
+ finish(null);
+ }, 90000);
+ try {
+ sendMessage({ type: "fix-webm-duration", id, blob, durationMs });
+ } catch (err) {
+ finish(null);
+ }
+ };
+
const getBlob = async () => {
if (
contentState.noffmpeg ||
diff --git a/src/pages/utils/acquireDisplayMedia.js b/src/pages/utils/acquireDisplayMedia.js
new file mode 100644
index 0000000..f9c9551
--- /dev/null
+++ b/src/pages/utils/acquireDisplayMedia.js
@@ -0,0 +1,26 @@
+// getDisplayMedia needs a focused, fully-active document or it rejects with
+// InvalidStateError (before any picker shows). Retry once on that after asking
+// the background to refocus the recorder tab; any other error (cancel, hardware
+// lock) rethrows unchanged. Pure w.r.t. injected deps so it's unit-testable.
+export async function acquireDisplayMediaWithFocusRetry({
+ getDisplayMedia,
+ constraints,
+ onReactivate,
+ delayMs = 250,
+}) {
+ try {
+ return await getDisplayMedia(constraints);
+ } catch (err) {
+ if (err?.name !== "InvalidStateError") throw err;
+ // Refocus the recorder tab, then retry once; a second failure propagates.
+ if (typeof onReactivate === "function") {
+ try {
+ await onReactivate();
+ } catch {}
+ }
+ if (delayMs > 0) {
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
+ }
+ return await getDisplayMedia(constraints);
+ }
+}
diff --git a/src/pages/utils/audioContextWatchdog.js b/src/pages/utils/audioContextWatchdog.js
index 3e8f2c0..37320d7 100644
--- a/src/pages/utils/audioContextWatchdog.js
+++ b/src/pages/utils/audioContextWatchdog.js
@@ -5,11 +5,28 @@
// emit silence, which the AudioEncoder encodes as an unflagged silent gap.
// Diagnostic-first: log the transition and retry resume every 2s, but don't tear
// down the recording, so user reports of "audio cut out" can be traced.
+//
+// Transitions route through the background diag-forward channel rather than
+// diagEvent directly: this runs in page realms (Web Audio has no SW context),
+// where diagEvent's session log is never initialized and would silently no-op.
+// Returns a live stats handle the caller can read at finalize time to attach
+// interruption totals to upload telemetry.
-import { diagEvent } from "./diagnosticLog";
+const forwardDiag = (event, data) => {
+ try {
+ chrome.runtime
+ .sendMessage({ type: "diag-forward", event, data })
+ .catch(() => {});
+ } catch {}
+};
export function attachAudioContextWatchdog(aCtx, label) {
- if (!aCtx || typeof aCtx.addEventListener !== "function") return;
+ const stats = {
+ interruptedCount: 0,
+ interruptedTotalMs: 0,
+ sawInterrupted: false,
+ };
+ if (!aCtx || typeof aCtx.addEventListener !== "function") return stats;
let resumeTimer = null;
let interruptedAt = null;
@@ -25,27 +42,27 @@ export function attachAudioContextWatchdog(aCtx, label) {
const onChange = () => {
try {
const state = aCtx.state;
- const detail = {
+ forwardDiag("audiocontext-statechange", {
label,
state,
sinceInterruptedMs: interruptedAt ? Date.now() - interruptedAt : null,
- };
- try { diagEvent("audiocontext-statechange", detail); } catch {}
+ });
// Only auto-resume "interrupted" (OS-driven). "suspended" is the user's
// pause flow; resuming it would silently un-pause a Pro recording.
if (state === "interrupted") {
- if (!interruptedAt) interruptedAt = Date.now();
+ if (!interruptedAt) {
+ interruptedAt = Date.now();
+ stats.interruptedCount += 1;
+ stats.sawInterrupted = true;
+ }
if (!resumeTimer) {
resumeTimer = setInterval(tryResume, 2000);
}
} else if (state === "running") {
if (interruptedAt) {
- try {
- diagEvent("audiocontext-resumed", {
- label,
- interruptedForMs: Date.now() - interruptedAt,
- });
- } catch {}
+ const interruptedForMs = Date.now() - interruptedAt;
+ stats.interruptedTotalMs += interruptedForMs;
+ forwardDiag("audiocontext-resumed", { label, interruptedForMs });
}
interruptedAt = null;
if (resumeTimer) {
@@ -55,6 +72,9 @@ export function attachAudioContextWatchdog(aCtx, label) {
} else if (state === "closed" || state === "suspended") {
// suspended = user pause, closed = teardown: stop the resume timer.
// Re-arms via statechange if it later returns to interrupted.
+ if (interruptedAt) {
+ stats.interruptedTotalMs += Date.now() - interruptedAt;
+ }
interruptedAt = null;
if (resumeTimer) {
clearInterval(resumeTimer);
@@ -67,4 +87,5 @@ export function attachAudioContextWatchdog(aCtx, label) {
try {
aCtx.addEventListener("statechange", onChange);
} catch {}
+ return stats;
}
diff --git a/src/pages/utils/screenCaptureMode.js b/src/pages/utils/screenCaptureMode.js
new file mode 100644
index 0000000..442c17f
--- /dev/null
+++ b/src/pages/utils/screenCaptureMode.js
@@ -0,0 +1,40 @@
+// Decides whether screen/window capture uses getDisplayMedia instead of
+// chrome.desktopCapture. macOS system audio only works via getDisplayMedia
+// (Chrome 141+/macOS 14.2+); desktopCapture has no macOS system-audio backend.
+// Core predicate is pure (unit-tested in tests/unit/).
+
+export function parseChromeMajor(ua) {
+ const m = (ua || "").match(/Chrom(?:e|ium)\/(\d+)/);
+ return m ? parseInt(m[1], 10) : 0;
+}
+
+export function isMacUserAgent(ua) {
+ return /Mac/i.test(ua || "");
+}
+
+// force = storage override (E2E tests / escape hatch); disabled = kill-switch.
+export function screenCaptureUsesDisplayMedia({
+ chromeMajor = 0,
+ isMac = false,
+ force = false,
+ disabled = false,
+} = {}) {
+ if (force === true) return true;
+ if (disabled === true) return false;
+ return isMac === true && Number(chromeMajor) >= 141;
+}
+
+// Resolves platform/version from navigator + the forceDisplayMediaScreen /
+// macSystemAudioCapture storage flags.
+export function shouldUseDisplayMediaForScreen(settings = {}) {
+ const ua =
+ typeof navigator !== "undefined" && navigator.userAgent
+ ? navigator.userAgent
+ : "";
+ return screenCaptureUsesDisplayMedia({
+ chromeMajor: parseChromeMajor(ua),
+ isMac: isMacUserAgent(ua),
+ force: settings.forceDisplayMediaScreen === true,
+ disabled: settings.macSystemAudioCapture === false,
+ });
+}