@@ -78,9 +78,12 @@ const attach = (event, webContents) => {
7878
7979 // Enable screen capture permissions for all webContents
8080 webContents . session . setPermissionRequestHandler ( ( webContents , permission , callback ) => {
81- if ( permission === 'media' ) {
81+ console . log ( `[PERMISSION DEBUG] Permission requested: "${ permission } " from webContents` )
82+ if ( permission === 'media' || permission === 'display-capture' ) {
83+ console . log ( `[PERMISSION DEBUG] Granting permission: "${ permission } "` )
8284 callback ( true )
8385 } else {
86+ console . log ( `[PERMISSION DEBUG] Denying permission: "${ permission } "` )
8487 callback ( false )
8588 }
8689 } )
@@ -415,15 +418,33 @@ const createWindow = (port) => {
415418 nativeWindowOpen : true ,
416419 contextIsolation : false ,
417420 nodeIntegrationInSubFrames : true ,
421+ enableRemoteModule : false ,
422+ experimentalFeatures : true ,
418423 preload : path . join ( __dirname , 'preload.js' )
419424 } ,
420425 } )
421426
427+ // Debug media device availability
428+ mainWindow . webContents . once ( 'did-finish-load' , ( ) => {
429+ console . log ( '[MEDIA DEBUG] Main window loaded, checking media devices availability...' )
430+ mainWindow . webContents . executeJavaScript ( `
431+ console.log('[MEDIA DEBUG] navigator.mediaDevices available:', !!navigator.mediaDevices);
432+ console.log('[MEDIA DEBUG] getDisplayMedia available:', !!(navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia));
433+ console.log('[MEDIA DEBUG] getUserMedia available:', !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia));
434+ if (navigator.mediaDevices && navigator.mediaDevices.getSupportedConstraints) {
435+ console.log('[MEDIA DEBUG] Supported constraints:', navigator.mediaDevices.getSupportedConstraints());
436+ }
437+ ` ) . catch ( err => console . error ( '[MEDIA DEBUG] Error checking media devices:' , err ) )
438+ } )
439+
422440 // Enable screen capture permissions
423441 mainWindow . webContents . session . setPermissionRequestHandler ( ( webContents , permission , callback ) => {
424- if ( permission === 'media' ) {
442+ console . log ( `[PERMISSION DEBUG] MainWindow permission requested: "${ permission } "` )
443+ if ( permission === 'media' || permission === 'display-capture' ) {
444+ console . log ( `[PERMISSION DEBUG] MainWindow granting permission: "${ permission } "` )
425445 callback ( true )
426446 } else {
447+ console . log ( `[PERMISSION DEBUG] MainWindow denying permission: "${ permission } "` )
427448 callback ( false )
428449 }
429450 } )
@@ -460,15 +481,20 @@ const loadNewWindow = (url, port) => {
460481 nativeWindowOpen : true ,
461482 contextIsolation : false ,
462483 nodeIntegrationInSubFrames : true ,
484+ enableRemoteModule : false ,
485+ experimentalFeatures : true ,
463486 preload : path . join ( __dirname , 'preload.js' )
464487 } ,
465488 } )
466489
467490 // Enable screen capture permissions
468491 win . webContents . session . setPermissionRequestHandler ( ( webContents , permission , callback ) => {
469- if ( permission === 'media' ) {
492+ console . log ( `[PERMISSION DEBUG] New window permission requested: "${ permission } "` )
493+ if ( permission === 'media' || permission === 'display-capture' ) {
494+ console . log ( `[PERMISSION DEBUG] New window granting permission: "${ permission } "` )
470495 callback ( true )
471496 } else {
497+ console . log ( `[PERMISSION DEBUG] New window denying permission: "${ permission } "` )
472498 callback ( false )
473499 }
474500 } )
@@ -614,9 +640,12 @@ document.querySelector("form").addEventListener("submit", (e) => {
614640
615641 // Set global permission handler for screen capture
616642 session . defaultSession . setPermissionRequestHandler ( ( webContents , permission , callback ) => {
617- if ( permission === 'media' ) {
643+ console . log ( `[PERMISSION DEBUG] Global session permission requested: "${ permission } "` )
644+ if ( permission === 'media' || permission === 'display-capture' ) {
645+ console . log ( `[PERMISSION DEBUG] Global session granting permission: "${ permission } "` )
618646 callback ( true )
619647 } else {
648+ console . log ( `[PERMISSION DEBUG] Global session denying permission: "${ permission } "` )
620649 callback ( false )
621650 }
622651 } )
0 commit comments