Closed Bug 1627414 Opened 5 years ago Closed 5 years ago

getDisplayMedia does not work when firefox is full screen on macOS

Categories

(Core :: WebRTC: Audio/Video, defect, P2)

74 Branch
Desktop
macOS
defect

Tracking

()

VERIFIED FIXED
mozilla77
Tracking Status
firefox-esr68 --- unaffected
firefox74 --- wontfix
firefox75 --- wontfix
firefox76 + verified
firefox77 + verified

People

(Reporter: matt.watson, Assigned: haik)

References

(Regression)

Details

(Keywords: enterprise, regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36

Steps to reproduce:

In MacOS 10.15.4 make Firefox full screen (clicking on the green icon in the header).
Open the dev tools and paste the following code:
navigator.mediaDevices.getDisplayMedia({ audio: true, video: true})
.then(function(stream) {
console.log(stream)
})
.catch(function(err) {
console.log(err)
});

In the firefox window select the window to share and click Allow
Back in the dev console there is an MediaStreamError name: "NotFoundError"

Actual results:

Firefox raised a MediaStreamError Name: NotFoundError

Expected results:

Should have allowed the window to be shared

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Widget: Cocoa
Product: Firefox → Core

Does this work if the window is not in fullscreen? I couldn't get this to work on my side.

Flags: needinfo?(matt.watson)

I think you have to grant Firefox some permissions to do the screensharing to make it work at all, but yes this does work for me not in fullscreen. The expected result in the javascript console is it should return a MediaStream object.

To grant Firefox the appropriate permissions I went to System Preferences -> Security & Privacy -> Find Screen Recording in the left list -> Make sure Firefox is enabled for screen recording.

I think this is only relevant on Catalina, but I'm not 100%

Flags: needinfo?(matt.watson)

Sending over to WebRTC to see if this is a legitimate and/or known issue.

Component: Widget: Cocoa → WebRTC

STRs:

  1. Open https://jan-ivar.github.io/dummy/gdm.html, click button, in the prompt, select the window to share and click Allow

Workaround:

  1. Set media.macos.screenrecording.oscheck.enabled to false in about:config

Regression range:

23:39.32 INFO: Narrowed inbound regression window from [77e54e76, 86d3343d] (3 builds) to [77e54e76, a2e0699b] (2 builds) (~1 steps left)
23:39.32 INFO: No more inbound revisions, bisection finished.
23:39.32 INFO: Last good revision: 77e54e76848ab510bb0a20e375e8692b0f21e5d8
23:39.32 INFO: First bad revision: a2e0699b6cb88cd88f1b0be00be031449a2d62fd
23:39.32 INFO: Pushlog:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=77e54e76848ab510bb0a20e375e8692b0f21e5d8&tochange=a2e0699b6cb88cd88f1b0be00be031449a2d62fd

Haik, this looks like the window name check we added in bug 1612006 breaks fullscreen. Is there a way we can detect the firefox window is fullscreen and bypass this oscheck?

Status: UNCONFIRMED → NEW
Component: WebRTC → WebRTC: Audio/Video
Ever confirmed: true
Flags: needinfo?(haftandilian)
Keywords: regression
OS: Unspecified → macOS
Priority: -- → P2
Regressed by: 1612006
Hardware: Unspecified → Desktop
Has Regression Range: --- → yes

Looking into this.

Assignee: nobody → haftandilian

@jib, when the browser is full screen, is it expected for the window sharing list to only include the current window and a fullscreen option?

Flags: needinfo?(haftandilian) → needinfo?(jib)

I imagine it's a limitation of the OS, since the comment 5 fiddle yields the same result in Chrome in fullscreen (Safari has no picker, always offering entire desktop only, so we don't learn much there).

Flags: needinfo?(jib)

When running in full screen, our check in Mac platform code nsCocoaUtils::GetScreenCapturePermissionState() always returns false causing the checkOSPermission() call in WebRTCParent.jsm to always return false making Firefox act as if it does not have OS permission to record the screen.

The bug is that the window list used in the nsCocoaUtils::GetScreenCapturePermissionState() heuristic is kCGWindowListOptionOnScreenOnly instead of kCGWindowListOptionAll. Apologies for the oversight. This case never occurred to me when implementing the heuristic.

With kCGWindowListOptionOnScreenOnly, when the browser is in full screen mode, the window list returned from CGWindowListCopyWindowInfo() does not include windows necessary for the heuristic to work. A small subset of windows is included (6 in my testing on 10.15.4) and none of window layers match CGWindowLevelForKey(kCGDockWindowLevelKey), CGWindowLevelForKey(kCGNormalWindowLevelKey), or any documented key.

The fix will be to change the code to use kCGWindowListOptionAll.

Change the GetScreenCapturePermissionState() heuristic to use the full window list instead of just on-screen windows to allow it it to work in full screen mode.

Pushed by haftandilian@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a7235bdaa392 getDisplayMedia does not work when firefox is full screen on macOS r=spohl
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77

@Matt, thanks for the report. This is now fixed in the latest Nightly build. Are you able to use Firefox Nightly to confirm that the problem is now fixed for you?

Flags: needinfo?(matt.watson)

I can confirm that this works fine on Firefox Nightly! Thanks!!!

This works for me on nightly. Thanks!

Flags: needinfo?(matt.watson)

Thank you both for verifying.

Comment on attachment 9140561 [details]
Bug 1627414 - getDisplayMedia does not work when firefox is full screen on macOS r?spohl!

Beta/Release Uplift Approval Request

  • User impact if declined: On macOS Catalina 10.15+, when the browser is in full screen mode, attempts to start screen sharing on a site like talky.io will fail. When in full screen mode, the MediaDevices.getUserMedia() API returns an error (NotFoundError: "The object can not be found here") indicating screen recording is not available.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce:
  1. Reset screen recording permissions by running the following command from the Terminal.app (in /Applications/Utilities). This will reset which applications have screen recording permissions in macOS -> System Preferences -> Security & Privacy -> Screen Recording.

tccutil reset ScreenCapture

  1. Launch the browser and enter full screen mode by clicking the green button in the top left corner of the window as described here https://support.apple.com/guide/mac-help/use-apps-in-full-screen-mchl9c21d2be/mac

  2. Use a site such as :jib's test page (https://jan-ivar.github.io/dummy/gdm.html) or talky.io to share the full screen. The first time this is attempted, a macOS dialog will display instructing you to go to System Preferences and allow Firefox to record the screen described here https://support.apple.com/guide/mac-help/control-access-to-screen-recording-on-mac-mchld6aa7d23/mac

  3. Still in full screen mode, reload the page, and attempt to share the full screen. Without the fix, sharing in full screen mode fails. If the application is not in full screen mode, sharing full screen should work.

  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): The change is small, limited to macOS, and only affects WebRTC screen sharing/recording. However, the change does affect WebRTC screen sharing which is a critical feature at this time.
  • String changes made/needed:
Attachment #9140561 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Whiteboard: [wfh]

Comment on attachment 9140561 [details]
Bug 1627414 - getDisplayMedia does not work when firefox is full screen on macOS r?spohl!

Fixes broken WebRTC screensharing when in fullscreen mode on macOS 10.15+. Approved for 76.0b6.

Attachment #9140561 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

Reproduced it on Firefox 75 (20200403170909)
Verified fixed on Firefox 76.0b6 (20200420031429)

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
Keywords: enterprise
Whiteboard: [wfh]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: