fix screen recording: resolve relative paths, buffer chunks, wait for encoder

This commit is contained in:
Tommy D. Rossi
2026-01-29 23:30:01 +01:00
parent db54c35b83
commit a9a40e1183
3 changed files with 69 additions and 3 deletions
+16 -2
View File
@@ -154,8 +154,22 @@ async function handleStartRecording(params: OffscreenStartRecordingMessage): Pro
console.log(`MediaRecorder stopped for tab ${tabId}`)
}
// Start with 1 second chunks
recorder.start(1000)
// Wait for MediaRecorder to actually start before returning.
// This ensures the encoder is initialized and ready to capture frames.
await new Promise<void>((resolve, reject) => {
const timeout = setTimeout(() => {
reject(new Error('MediaRecorder failed to start within 5 seconds'))
}, 5000)
recorder.onstart = () => {
clearTimeout(timeout)
console.log(`MediaRecorder started for tab ${tabId}`)
resolve()
}
// Start with 1 second chunks
recorder.start(1000)
})
return { success: true, tabId, startedAt, mimeType: 'video/mp4' }
} catch (error: any) {