fix(electron): crash when cancelling screen picker
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:
parent
694f4371ce
commit
1da6c76017
1 changed files with 4 additions and 4 deletions
|
|
@ -134,7 +134,7 @@ function createWindow() {
|
||||||
session.defaultSession.setDisplayMediaRequestHandler(async (_request, callback) => {
|
session.defaultSession.setDisplayMediaRequestHandler(async (_request, callback) => {
|
||||||
const sources = await desktopCapturer.getSources({ types: ['screen', 'window'], thumbnailSize: { width: 320, height: 180 } });
|
const sources = await desktopCapturer.getSources({ types: ['screen', 'window'], thumbnailSize: { width: 320, height: 180 } });
|
||||||
if (sources.length === 0) {
|
if (sources.length === 0) {
|
||||||
callback({});
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -232,7 +232,7 @@ document.getElementById('cancelBtn').addEventListener('click', () => {
|
||||||
try { fs.unlinkSync(tmpFile); } catch {}
|
try { fs.unlinkSync(tmpFile); } catch {}
|
||||||
|
|
||||||
if (!selection) {
|
if (!selection) {
|
||||||
callback({});
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selectedId = typeof selection === 'string' ? selection : selection.id;
|
const selectedId = typeof selection === 'string' ? selection : selection.id;
|
||||||
|
|
@ -241,7 +241,7 @@ document.getElementById('cancelBtn').addEventListener('click', () => {
|
||||||
if (chosen) {
|
if (chosen) {
|
||||||
callback(withAudio ? { video: chosen, audio: 'loopback' } : { video: chosen });
|
callback(withAudio ? { video: chosen, audio: 'loopback' } : { video: chosen });
|
||||||
} else {
|
} else {
|
||||||
callback({});
|
callback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -252,7 +252,7 @@ document.getElementById('cancelBtn').addEventListener('click', () => {
|
||||||
if (!resolved) {
|
if (!resolved) {
|
||||||
resolved = true;
|
resolved = true;
|
||||||
ipcMain.removeListener(PICKER_CHANNEL, onPickerResult);
|
ipcMain.removeListener(PICKER_CHANNEL, onPickerResult);
|
||||||
callback({});
|
callback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue