elan-ev / opencast-studio

Web-based recording studio for Opencast
https://studio.opencast.org
MIT License
50 stars 47 forks source link

Fix safari not capturing both display and camera #1127

Closed owi92 closed 1 year ago

owi92 commented 1 year ago

Safari needs a "user gesture" (i.e. a button click) to call getDisplayMedia. Calling the user capture first would prevent the display capture to register the triggering button click, so this switches the ordering (for safari only). So in Safari, the user will always get asked to share their screen before they get asked to share their webcam.

(I did notice that when calling both startUserCapture and startDisplayCapture inside a Promise.all(), the ordering in Safari is consistently switched again, but with no issues (meaning user capture is asked before screen capture). This would be preferrable, but I'm not sure if we can rely on this always being the case. So in the interest of consistency I chose to just call startDisplayCapture first...)

Closes #934

lkiesow commented 1 year ago

I'm wondering if the code for Safari wouldn't actually work on in all major vrowsers. Do we really need two code branches here?

LukasKalbertodt commented 1 year ago

It's complicated. The current order was specifically chosen in commit 66865d3609348c17af51a9aab20bf5fda654dafc

Request webcam before display share

If sharing a specific window from the desktop, some browsers bring that window into the foreground. If it does not overlap the browser window, users might be confused as the webcam is not requested. This only happens after the browser window is focused again. Changing the order works around this problem.

Once we fix #403 is fixed, we might be able to remove the extra branch here. The branch is annoying but we didn't want to risk maybe making the workflow for some people worse. Or well, just changing anything might annoy people.