Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(record): drop a pending microphone turn-on once the take starts

EtienneLescot6e27423dd964
diff --git a/src/components/ai-edition/v4/RecStage.test.tsx b/src/components/ai-edition/v4/RecStage.test.tsx
index ca3d7c3e7..7ba2d33c3 100644
--- a/src/components/ai-edition/v4/RecStage.test.tsx
+++ b/src/components/ai-edition/v4/RecStage.test.tsx
@@ -305,6 +305,20 @@ describe("RecStage controls", () => {
expect(toast.error).not.toHaveBeenCalled();
});
+ it("never turns the microphone on after Start recording, when its check ends late", async () => {
+ const { getRecordingPrefs, setRecordingPrefs } = stubRecordingPrefs({ micEnabled: false });
+ stubMediaDevices([{ kind: "audioinput", deviceId: "mic-1" }]);
+ const { onStartRecording } = renderRecStage();
+ await waitFor(() => expect(getRecordingPrefs).toHaveBeenCalled());
+
+ fireEvent.click(pill("rec.microphone"));
+ fireEvent.click(screen.getByRole("button", { name: /rec\.startRecording/ }));
+
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(onStartRecording).toHaveBeenCalled();
+ expect(setRecordingPrefs).not.toHaveBeenCalledWith({ micEnabled: true });
+ });
+
it("lets a second click during the microphone check take the first one back", async () => {
const { getRecordingPrefs, setRecordingPrefs } = stubRecordingPrefs({ micEnabled: false });
stubMediaDevices([{ kind: "audioinput", deviceId: "mic-1" }]);
diff --git a/src/components/ai-edition/v4/RecStage.tsx b/src/components/ai-edition/v4/RecStage.tsx
index c34ac79b2..9a87698f8 100644
--- a/src/components/ai-edition/v4/RecStage.tsx
+++ b/src/components/ai-edition/v4/RecStage.tsx
@@ -596,7 +596,15 @@ export function RecStage({
{t("rec.cancel")}
</button>
) : null}
- <button type="button" className={styles.bigRecBtn} onClick={onStartRecording}>
+ <button
+ type="button"
+ className={styles.bigRecBtn}
+ onClick={() => {
+ // The take is decided now: a microphone check still running must not turn it on.
+ micTurningOn.current = false;
+ onStartRecording();
+ }}
+ >
<span className={styles.bigRecDot} aria-hidden />
{t("rec.startRecording")}
</button>
diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsx
index b803eba0d..4a310e07d 100644
--- a/src/components/launch/LaunchWindow.tsx
+++ b/src/components/launch/LaunchWindow.tsx
@@ -897,6 +897,10 @@ export function LaunchWindow() {
// Refuses a microphone the OS does not list, as the camera toggle does (#995). A second
// click while the check runs takes the first one back: the last click wins.
const micTurningOn = useRef(false);
+ // A take that starts while the check runs was decided without the microphone: keep it so.
+ useEffect(() => {
+ if (controlsLocked) micTurningOn.current = false;
+ }, [controlsLocked]);
const toggleMicrophone = useCallback(() => {
if (controlsLocked) return;
if (microphoneEnabled) {