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) => {
|
||||
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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue