Screen sharing fail on Firefox desktop until user click at least once on the jitsi iframe

Hello all,
I have a strange issue. I used the external API to embed a video-conf in my website and also deployed a custom jitsi server.

const options = {
        roomName: `${support_id}${myInfo.jroom_pw}`,
        parentNode: document.querySelector('#panelarea'),
    };
    api = new JitsiMeetExternalAPI(myInfo.server, options);

Everything work fine, user can join the conference, the video is working etc.
Instead of showing jitsi-meet default toolbar, I hide it and provide my own buttons outside of the iframe. One of them is for sharing the screen. This button just calls the api like this :

api.executeCommand('toggleShareScreen');

However, on firefox, if an user try to share his screen without having ever clicked anywhere on the iframe before, then sending the toggleShareScreen command fail and I get this error in the console.

2020-03-05T10:36:38.338Z [modules/RTC/RTCUtils.js] : Using the new gUM flow Logger.js:154:22

2020-03-05T10:36:38.338Z [modules/RTC/ScreenObtainer.js] : Using getDisplayMedia for screen sharing Logger.js:154:22

2020-03-05T10:36:38.339Z [features/base/tracks] <E/</<>: Failed to create local tracks

Array [ “desktop” ]

Object { name: “gum.chrome_extension_user_canceled”, message: “User canceled Chrome’s screen sharing prompt”, stack: “a@https://jitsi.-----------.com/libs/lib-jitsi-meet.min.js?v=3863:6:114711\nobtainScreenFromGetDisplayMedia/<@https://jitsi.-----------.com/libs/lib-jitsi-meet.min.js?v=3863:6:175762\n” }

Logger.js:154:22

2020-03-05T10:36:38.342Z [conference.js] : Failed to switch to screensharingObject { name: “gum.chrome_extension_user_canceled”, message: “User canceled Chrome’s screen sharing prompt”, stack: “a@https://jitsi.-----------.com/libs/lib-jitsi-meet.min.js?v=3863:6:114711\nobtainScreenFromGetDisplayMedia/<@https://jitsi.-----------.com/libs/lib-jitsi-meet.min.js?v=3863:6:175762\n” }

If the user clicked at least once anywhere in the iframe, then the screen sharing work fine.
This issue doesn’t happen on chrome. Any idea how to workaround that problem ? I tried to set the focus or simulate a click on the iframe, but because it’s a cross-domain iframe the browser refuse.

1 Like

I think this might be a browser policy, where that is not allowed unless the user has interacted with the page.

1 Like

Thanks, that would make sense.
Still slightly strange, because there is no such issue with webcam or mic policy, the prompt to the user to allow them appear at the start of the call without any interaction at all.

Btw, due to this issue, the feature startScreenSharing = true in config.js also doesn’t work with firefox. When the call starts, the screen sharing fails with the same error I show above in the console, and only the mic get turned on (webcam is off)
Should I file a bug ?

Yes, please, do file a bug. I also just noticed some Chrome shenanigans in your logs, maybe some incorrect code path is being taken.

Done. Thank you.

Urg, wrong repo, sorry about that, here is the proper issue :

Thanks!

This morning our firefox updated to version 74, and now with our deployment the screensharing always fail, even with jitsi own screensharing button inside the iframe. With firefox 72 at least the screensharing worked with jitsi own button.

It’s the same error message, mentioning Chrome for some reason. Any idea what’s going on ?

2020-03-16T03:48:33.013Z [features/base/tracks] <w/</<>: Failed to create local tracks
Array [ “desktop” ]
Object { name: “gum.chrome_extension_user_canceled”, message: “User canceled Chrome’s screen sharing prompt”, stack: “a@https://jitsi.service.trk..com/libs/lib-jitsi-meet.min.js?v=3863:6:114711\nobtainScreenFromGetDisplayMedia/<@https://jitsi.service.trk..com/libs/lib-jitsi-meet.min.js?v=3863:6:175762\n” }

app.bundle.min.js:117:2379

2020-03-16T03:48:33.016Z [conference.js] : Failed to switch to screensharingObject { name: “gum.chrome_extension_user_canceled”, message: “User canceled Chrome’s screen sharing prompt”, stack: “a@https://jitsi.service.trk..com/libs/lib-jitsi-meet.min.js?v=3863:6:114711\nobtainScreenFromGetDisplayMedia/<@https://jitsi.service.trk..com/libs/lib-jitsi-meet.min.js?v=3863:6:175762\n” }

@saghul I think I found the issue about firefox 74 failure !
In jitsi-meet/modules/API/external/external_api.js

-this._frame.allow = 'camera; microphone'; 
+ this._frame.allow = 'camera; microphone; display-capture'; 

To allow firefox to capture the screen for screen sharing. This is because firefox 74 introduced a new feature policy

After applying the fix below I’m back to my original issue, need to click at least once on the iframe for firefox to allow screensharing :slight_smile:

Edit: pull request done

1 Like

Thanks for sending the PR! As for the need of an interaction, I’m not sure what we can do if it’s enforced by the browser…

Seeing this integrated in https://github.com/jitsi/jitsi-meet/releases/tag/jitsi-meet_4300 should this already be in meet.ji.si ?
I am stil unable to share a screen in Firefox 74.0. Not sure which iframe I would have to click first to make this work though.

Sorry, but this bug was very specific to the external-api and https://meet.jit.si/ does not use it, so it’s not related. If you have screen sharing issue on https://meet.jit.si/ you should probably open another thread.