Skip to content

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

Fix camera recovery after navigation in local recorder

Alyssa Xf379a5fa594c
diff --git a/src/manifest.json b/src/manifest.json
index 224e8af..df42ce9 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -3,7 +3,7 @@
"name": "__MSG_extName__",
"description": "__MSG_extDesc__",
"default_locale": "en",
- "version": "4.3.0",
+ "version": "4.3.1",
"background": {
"service_worker": "background.bundle.js"
},
diff --git a/src/pages/Camera/Camera.jsx b/src/pages/Camera/Camera.jsx
index 56a60e3..ba14259 100644
--- a/src/pages/Camera/Camera.jsx
+++ b/src/pages/Camera/Camera.jsx
@@ -1,7 +1,11 @@
import React, { useEffect, useRef, useState } from "react";
import Background from "./components/Background";
import { useCameraContext } from "./context/CameraContext";
-import { getCameraStream, stopCameraStream } from "./utils/cameraUtils";
+import {
+ getCameraStream,
+ stopCameraStream,
+ surfaceHandler,
+} from "./utils/cameraUtils";
import { setupHandlers } from "./messaging/handlers";
const Camera = () => {
@@ -110,6 +114,23 @@ const Camera = () => {
});
}, [videoRef.current]); // Will run once when videoRef is set
+ // After the camera stream is ready, check if we should re-enter PiP.
+ // This handles the case where the user navigated while recording a monitor β€”
+ // the old PiP was destroyed with the old page, so we need to re-enter it
+ // once the new camera iframe has a live stream.
+ useEffect(() => {
+ if (!videoRef.current || !streamRef.current?.active) return;
+
+ chrome.storage.local.get(
+ ["surface", "recording"],
+ (result) => {
+ if (result.recording && result.surface) {
+ surfaceHandler({ surface: result.surface }, videoRef);
+ }
+ },
+ );
+ }, [videoRef.current, streamRef.current?.active]);
+
// Handle PiP events
const handleEnterPip = () => {
setPipMode(true);
diff --git a/src/pages/Content/context/messaging/handlers.js b/src/pages/Content/context/messaging/handlers.js
index edf715c..928b4ca 100644
--- a/src/pages/Content/context/messaging/handlers.js
+++ b/src/pages/Content/context/messaging/handlers.js
@@ -800,10 +800,16 @@ export const setupHandlers = () => {
updateFromStorage(true, sender.id);
}
} else {
+ // After navigation, PiP is always destroyed (the iframe that owned it
+ // was torn down with the old page). Set pipEnded: true so the inline
+ // camera overlay is visible immediately. If the camera iframe
+ // successfully re-enters PiP later, a "pip-started" message will flip
+ // this back to false.
setContentState((prev) => ({
...prev,
showExtension: true,
recording: true,
+ pipEnded: true,
}));
updateFromStorage(false, sender.id);
}