fix(electron): crash when cancelling screen picker
All checks were successful
Build & Deploy / build (push) Successful in 59s
Build & Deploy / deploy (push) Successful in 3s
Build & Deploy / bump-version (push) Successful in 5s

Calling callback({}) with an empty object caused Electron to throw
"Video was requested, but no video stream was provided". The correct
way to cancel/deny the request is callback() with no arguments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-10 23:06:48 +01:00
parent 694f4371ce
commit 1da6c76017

View file

@ -134,7 +134,7 @@ function createWindow() {
session.defaultSession.setDisplayMediaRequestHandler(async (_request, callback) => {
const sources = await desktopCapturer.getSources({ types: ['screen', 'window'], thumbnailSize: { width: 320, height: 180 } });
if (sources.length === 0) {
callback({});
callback();
return;
}
@ -232,7 +232,7 @@ document.getElementById('cancelBtn').addEventListener('click', () => {
try { fs.unlinkSync(tmpFile); } catch {}
if (!selection) {
callback({});
callback();
return;
}
const selectedId = typeof selection === 'string' ? selection : selection.id;
@ -241,7 +241,7 @@ document.getElementById('cancelBtn').addEventListener('click', () => {
if (chosen) {
callback(withAudio ? { video: chosen, audio: 'loopback' } : { video: chosen });
} else {
callback({});
callback();
}
};
@ -252,7 +252,7 @@ document.getElementById('cancelBtn').addEventListener('click', () => {
if (!resolved) {
resolved = true;
ipcMain.removeListener(PICKER_CHANNEL, onPickerResult);
callback({});
callback();
}
});
});