Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDisplayMedia() has permission issue #2600

Closed
devtool20000 opened this issue Sep 14, 2021 · 53 comments
Closed

getDisplayMedia() has permission issue #2600

devtool20000 opened this issue Sep 14, 2021 · 53 comments

Comments

@devtool20000
Copy link

Describe the bug

Hi I try to call getDisplayMedia() but got permission issue, see details below, thanks!

To Reproduce

Steps to reproduce the behavior:

  1. Check out the sample code from here
  2. cd to src-tauri/my-app run yarn && yarn start, this start the react dev server
  3. in root folder run yarn tauri dev
  4. After the application starts, click the "test" button, this will trigger the getDisplayMedia() api. Click the "Inspect Element", you will see the error in console "Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."

Expected behavior

It should call the getDisplayMedia() successfully without error.

Screenshots

image

Platform and Versions (required):

Operating System - Mac OS, version 11.5.2 X64

Node.js environment
  Node.js - 14.17.2
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 6.14.13
  yarn - 1.22.4

Rust environment
  rustc - 1.55.0
  cargo - 1.55.0

App directory structure
/node_modules
/src-tauri
/.idea

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - my-app/build
  devPath - http://localhost:3000


Additional context

I already add the Info.plist under src-tauri with the following configuration

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSCameraUsageDescription</key>
	<string>Request camera access for WebRTC</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>Request microphone access for WebRTC</string>
</dict>
</plist>

The getUserMedia() works properly, but getDisplayMedia() didn't. I try to run the same react app inside safari and the getDisplayMedia() works properly in it.

Stack Trace

@alectrocute
Copy link

Side effect of #2317?

@cliqer
Copy link

cliqer commented Jun 27, 2022

I am experiencing the same error.

NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

and on the server I get:

+++     0x60000040ee60  0       1       914797062695125

My plist is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.automation.apple-events</key>
    <true/>
    <key>com.apple.security.device.usb</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.inherit</key>
    <true/>
  </dict>
</plist>

and the request is:

  return await navigator.mediaDevices.getDisplayMedia({
    audio: false,
    video: {
      //@ts-ignore
      mandatory: {
        displaySurface: 'monitor', // tried 'desktop', 'screen', 'display'
        chromeMediaSourceId: 1,
        minWidth: 1280,
        maxWidth: 1680,
        minHeight: 720,
        maxHeight: 1050
      }
    }
  }).then(stream => console.log(stream))
    .catch(e => console.log(e))

Also window.isSecureContext returns true on all platforms.
Any solutions?

@cliqer
Copy link

cliqer commented Aug 5, 2022

navigator.mediaDevices.getDisplayMedia throw NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Can someone please help with this problem for Webkit on MacOS?

@daniel-abramov
Copy link

daniel-abramov commented Aug 15, 2022

@cliqer, I'm not an expert, so not sure if what I'm going to say would make any sense, but AFAIK there is no such thing as chromeMediaSourceId in the WebRTC spec. I assume you might be using the chromeMediaSourceId as this is something you would use with Electron when calling their getUserMedia function to capture a specific window.

It seems like this is very specific to the Chromium engine and Electron even implemented an extension/helper to handle the chromeMediaSourceId inside getUserMedia().

I'm not sure these could work with getDisplayMedia and Tauri without implementing some sort of a Tauri plugin that would have a functionality similar to the desktopCapturer in Electron.

@cliqer
Copy link

cliqer commented Aug 15, 2022

@application-developer-DA you are totally right.

WKWebView does not support getDisplayMedia and currently, there is no way to share a screen on MacOS.

There are a few solutions that could be a workaround but need implementation:

This is a mandatory feature of our application as we need webrtc screen sharing and the only problem we have as to port it to Tauri/rust from electron is the luck of capturing the video stream of the screen.

Any good soul out there with the knowledge to port electron's implementation of getUserMedia or getDisplayMedia to WKWebView or can recommend any other solutions for Tauri/rust?

Any recommendations would be very much appreciated.

@daniel-abramov
Copy link

This is a mandatory feature of our application as we need webrtc screen sharing and the only problem we have as to port it to Tauri/rust from electron is the luck of capturing the video stream of the screen.

Yeah, right. We're in the same boat.

Any good soul out there with the knowledge to port electron's implementation of getUserMedia or getDisplayMedia to WKWebView or can recommend any other solutions for Tauri/rust?
Any recommendations would be very much appreciated.

I think the only "viable" (not really unfortunately) option would be using webrtc-rs, but the client stack for the WebRTC has not yet been implemented and is part of a roadmap. There is an open issue to create an example to use it with Tauri.

I think basically you're left with 2 options here:

  1. Rely upon Electron (probably not a desirable option if you're choosing Tauri for the same reason we do).
  2. Implement some sort of a Tauri Plugin that would bring the desired support of the WebRTC Screen Capturing. This might take a decent amount of time before it matches the feature-set of Electron's desktopCapturer though (Disclaimer: I don't have much experience with Tauri plugins, so perhaps this whole idea is also far away from being optimal).

@towe75
Copy link

towe75 commented Apr 1, 2023

I'm not a tauri user but i came across the same problem and found this post.

After quite some digging i was able to get a acceptable solution for my WKWebView based project..

a) ensure to request screen capture permissions for the app itself via CGPreflightScreenCaptureAccess() / CGRequestScreenCaptureAccess()

b) it's necessary to implement a private delegate. I found this here: SafeExamBrowser/seb-mac#150

Try this minimal example that i derived from my own project:

@protocol WKUIDelegatePrivateTauri <NSObject>

typedef NS_OPTIONS(NSUInteger, _WKCaptureDevices) {
    _WKCaptureDeviceMicrophone = 1 << 0,
    _WKCaptureDeviceCamera = 1 << 1,
    _WKCaptureDeviceDisplay = 1 << 2,
};

- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler;
@end

@interface TauriDelegate : NSObject <WKUIDelegatePrivateTauri>

@end

@implementation TauriDelegate

- (void)_webView:(WKWebView *)webView
      requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url
      mainFrameURL:(NSURL *)mainFrameURL
      decisionHandler:(void (^)(BOOL authorized))decisionHandler
{
    decisionHandler(true);
}

@end

With this i was able to get a media stream. Although the chooser is still missing. It shares the screen with the browser view on it.

Maybe the situation improves with a later webkit version. Seems they work on it: WebKit/WebKit#9789

Hope this helps you!
Who knows, maybe i will use tauri for a future project ;-)

@veaba
Copy link

veaba commented May 11, 2023

+1
Can't record audio.
image

@ZhoufangErqiangu
Copy link

ZhoufangErqiangu commented Aug 25, 2023

i got same error on ubuntu 22.04. i am sure my code works well in browsers.

@FabianLars
Copy link
Member

This issue is about macOS. On Linux, even though it's the same error message, the cause is different == webrtc just isn't a thing in webkitgtk yet (to be exact, it is being worked on but hidden behind a build flag only distro maintainers can flip)

@stolinski
Copy link

Has anyone managed to get this working? Just calling getDisplayMedia leads to the same errors @cliqer was having in 2022.

@cliqer
Copy link

cliqer commented Sep 6, 2023

@stolinski, this has been fixed in Webkit v16.1 on Ventura.
This means that getDisplayMedia only works if your Tauri app runs on Ventura with the latest Safari.

@stolinski
Copy link

Screenshot 2023-09-05 at 6 32 38 PM

Wild I'm on Sonoma and hitting permissions issues. I need to find how to reset permissions in this app if they have been denied somehow.

@cliqer
Copy link

cliqer commented Sep 6, 2023

@stolinski try the following if you haven't. Hope it helps:

// src-tauri/info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSCameraUsageDescription</key>
	<string>Request camera access for WebRTC</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>Request microphone access for WebRTC</string>
</dict>
</plist>
//src-tauri/Release.entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.automation.apple-events</key>
    <true/>
    <key>com.apple.security.device.usb</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.inherit</key>
    <true/>
  </dict>
</plist>

in your tauri.conf.json:

{
 {
 "tauri": {
  "macOSPrivateApi": true,
  "bundle": {
      "active": true,
      "macOS": {
        "entitlements": "Release.entitlements",
        "exceptionDomain": "",
        "frameworks": [],
      },
      "resources": [],
      "targets": ["app"],
      }
    },
    "security": {
      "csp": null
    }
  }
}

@stolinski
Copy link

Thanks for the help @cliqer but sadly no dice. Still hitting the same permissions error.

@stolinski
Copy link

So I can confirm that getDisplayMedia has been added to WKWebView it does not work within Tauri still because there is no permission dialog and therefore the request for getDisplayMedia will always return a permission denied error. So this seems to be an issue with Tauri as is right now as you are unable to grant permissions to use getDisplayMedia.

@cliqer
Copy link

cliqer commented Sep 6, 2023

@stolinski it works for me and dialogue is being displayed in the latest Tauri v1 and Ventura 13.5.1 (22G90):
image
I am requesting it simply like this:

return await navigator.mediaDevices.getDisplayMedia({
            audio: false,
            video: true
})

@stolinski
Copy link

Is this in development? How frustrating. I'm on Sonoma, latest Tauri v1 and just getting the permissions failed instantly with the same getDisplayMedia code to request.

Do you know of a way to reset permissions completely on a Tauri app? I've tried building for production and got the same permission failure immediately.

@stolinski
Copy link

Just fired up a totally fresh Tauri app, requested

navigator.mediaDevices.getDisplayMedia({
            audio: false,
            video: true
})

And got hit with the same permission denied error without a dialogue. Now wondering if this is a Sonoma related issue. (on 14.0 Beta (23A5337a))

@stolinski
Copy link

Small update on this.

I can confirm that the permissions prompt is being issued on MacOS v13 but not on v14, which is still unreleased although in rc. I'll update again once the OS is official.

[✔] Environment
    - OS: Mac OS 14.0.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.71.1 (eb26296b5 2023-08-03)
    ✔ Cargo: 1.71.1 (7f1d04c00 2023-07-29)
    ✔ rustup: 1.26.0 (2023-04-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.5.0
    - pnpm: 8.5.0
    - yarn: 1.22.19
    - npm: 9.8.0

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.14
    - tauri-build [RUST]: 2.0.0-alpha.8
    - wry [RUST]: 0.33.0
    - tao [RUST]: 0.22.2
    - @tauri-apps/api [NPM]: 1.4.0
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.14

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

@seanaye
Copy link

seanaye commented Oct 3, 2023

I'm on tauri v2 and MacOS 13.5.1. Sometime the getDisplayMedia call is really long, like multiple seconds, when my app is not doing anything, completely idle. Sometime it the permission dialog appears instantly and sometimes it takes up to 30seconds. Should I open this as a separate issue?

@cliqer
Copy link

cliqer commented Oct 3, 2023

Upgraded to Sonoma v14 and previous implementation doesn't work anymore.
I assume this has to do with Safari 17 changes in WebRTC.

@GorIvanov
Copy link

Same in the linux (Arch)!

getUserMedia error:
NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

webkit2gtk version is 2.42.1-1
It should work fine with webRTC, but.....

Is there any thought when this will be fixed?

@FabianLars
Copy link
Member

No idea when this will be fixed, the webkitgtk didn't gave any ETAs or hints but they are actively working on it.

Oh and to be clear, Linux does not have webrtc support yet so there isn't any "bug" preventing it, it's just not there yet.

@tarushnagpal
Copy link

Upgraded to Sonoma v14 and previous implementation doesn't work anymore.
I assume this has to do with Safari 17 changes in WebRTC.

@cliqer I am not sure that is the case, I just launched a simple WebView from xcode with a target of Sonoma 14.0 and did a simple navigator.mediaDevices.getDisplayMedia() and it worked, this might be something tauri specific not sure though

@cliqer
Copy link

cliqer commented Nov 23, 2023

@cliqer Were you able to get this to work in MacOS?

@tarushnagpal Unfortunately no

@tarushnagpal
Copy link

@cliqer Were you able to get this to work in MacOS?

@tarushnagpal Unfortunately no

Damn, Launching a webview in a fresh xcode app and calling a getDisplayMedia works just fine, has to be something with how we instantiate the web view from tauri, will get time to take a look over the weekend hopefully 🤞.

@seanaye
Copy link

seanaye commented Nov 27, 2023

@tarushnagpal any updates?

@tarushnagpal
Copy link

Was able to identify and fix the issue here tauri-apps/wry#1107, thanks to @pewsheen recognising where the bug resided!

@seanaye
Copy link

seanaye commented Jan 17, 2024

awesome, thanks! Can this issue be closed now?

@FabianLars
Copy link
Member

If someone using the latest tauri version and macos 14 can confirm that this pr helped, yes :)

@cliqer
Copy link

cliqer commented Jan 18, 2024

I checked on the latest v2.alpha with Sonoma, and it works.
Unfortunately, it doesn't work on v1; I had to migrate my project :/

@tarushnagpal
Copy link

tarushnagpal commented Jan 18, 2024

@cliqer I think the latest tauri v1 doesn't have the latest wry package, it was only released in wry v0.35.1, What I have done in my release pipeline is use my own "local" version of tauri with a changed Cargo.toml for wry runtime pointing to 0.35.1

@FabianLars
Copy link
Member

Cool, thanks for confirming. Backporting it to wry 0.24 (the version tauri v1 uses) should be fairly straightforward.

@matthiasg
Copy link

@FabianLars not possible in 1.5.4 yet correct ?

@FabianLars
Copy link
Member

correct

@matthiasg
Copy link

Any work scheduled to backport ?

@FabianLars
Copy link
Member

no, we're focused on getting v2 to beta right now. if someone opens a pr we can take a look though.

@nzoschke
Copy link

nzoschke commented Jan 31, 2024

Thanks, in general this is working for me with V2 and the Info.plist.

But with await navigator.mediaDevices.enumerateDevices() I see devices missing in the Tauri app that are available in standard OSX Safari app.

await navigator.mediaDevices.getUserMedia({
  audio: true,
  video: false,
});
var devices = await navigator.mediaDevices.enumerateDevices()
console.log(JSON.stringify(devices));

Tauri:

[
  {"deviceId":"5FF5BAB0009113ACC1477BDA0A1EA60FF64D5CC7","kind":"audioinput","label":"MacBook Pro Microphone","groupId":"19306579CF9380E2372D7691ACE283DC31F4AE7B"},
  {"deviceId":"97062E9CE4E98A8320BB77F306345F12C07B5A53","kind":"audioinput","label":"Noah’s iPhone Microphone","groupId":"658F702E23F4D59C4D4CFE26C601542AFBFC64BA"},
  {"deviceId":"C8645C00DC77A82269219035D29208FC86D836DD","kind":"videoinput","label":"FaceTime HD Camera","groupId":""},
  {"deviceId":"2E8657E4F1B108EF7CFD060F2BF66A340E221F7D","kind":"videoinput","label":"OBS Virtual Camera","groupId":""},
  {"deviceId":"084BE7A852816C49220C06FA8DF0ED0265EEB29F","kind":"videoinput","label":"Noah’s iPhone Camera","groupId":""},
  {"deviceId":"2D227FB9C6D1138E1769DFE648589478ADCDEF4B","kind":"videoinput","label":"Noah’s iPhone Desk View Camera","groupId":""}
]

Safari Desktop:

[
  {"deviceId":"52ABD94C026B20C3FF3AF37F701E156A1BE7557A","kind":"audioinput","label":"MacBook Pro Microphone","groupId":"082C98394E90C47939E93C4A521FF1E982B9C215"},
  {"deviceId":"3CD54FEBE4DEFCBE248BFD371AD7D1CEED8D417E","kind":"audioinput","label":"BlackHole 16ch","groupId":"F71A04BCA6C2953330B04D6A356896A85DC10F8B"},
  {"deviceId":"279BC0FB9937E89F18F1A04DFA531855FFE2F8DF","kind":"audioinput","label":"XONE 96 USB 1","groupId":"9A76BF4CBE512A38ABC52BA057DDFA3A8B6AA31A"},
  {"deviceId":"F5AEE340A817CCE0D3687ECAE87B0572CD2004B5","kind":"audioinput","label":"Noah’s iPhone Microphone","groupId":"AA5084E4581D1676318EB719F7C8A57951D19576"},
  {"deviceId":"99C9D3E03D55E4E77505F6F1262951F7EC63D8AF","kind":"videoinput","label":"FaceTime HD Camera","groupId":""},
  {"deviceId":"8A5CF3B9CA0470C0F011F520A3E95B25A8A3A5DE","kind":"videoinput","label":"OBS Virtual Camera","groupId":""},
  {"deviceId":"0D5F60A9F4499ABE928B9F7FE9AEE1639B8A5AB1","kind":"videoinput","label":"Noah’s iPhone Camera","groupId":""},
  {"deviceId":"8D37863FA87C4452BBC4477D8839B217FD106677","kind":"videoinput","label":"Noah’s iPhone Desk View Camera","groupId":""}
]

The two devices missing are BlackHole 16ch which is a virtual audio device from https://github.com/ExistentialAudio/BlackHole and XONE 96 USB 1 which is an external USB soundcard.

I'll keep digging into if its possible to get access to these devices in Tauri / wry, or Swift / WKWebview, but asking here in case anyone else knows.

@aryavsaigal
Copy link

Thanks, in general this is working for me with V2 and the Info.plist.

But with await navigator.mediaDevices.enumerateDevices() I see devices missing in the Tauri app that are available in standard OSX Safari app.

var devices = await navigator.mediaDevices.enumerateDevices()
console.log(JSON.stringify(devices));

Tauri:

[
  {"deviceId":"5FF5BAB0009113ACC1477BDA0A1EA60FF64D5CC7","kind":"audioinput","label":"MacBook Pro Microphone","groupId":"19306579CF9380E2372D7691ACE283DC31F4AE7B"},
  {"deviceId":"97062E9CE4E98A8320BB77F306345F12C07B5A53","kind":"audioinput","label":"Noah’s iPhone Microphone","groupId":"658F702E23F4D59C4D4CFE26C601542AFBFC64BA"},
  {"deviceId":"C8645C00DC77A82269219035D29208FC86D836DD","kind":"videoinput","label":"FaceTime HD Camera","groupId":""},
  {"deviceId":"2E8657E4F1B108EF7CFD060F2BF66A340E221F7D","kind":"videoinput","label":"OBS Virtual Camera","groupId":""},
  {"deviceId":"084BE7A852816C49220C06FA8DF0ED0265EEB29F","kind":"videoinput","label":"Noah’s iPhone Camera","groupId":""},
  {"deviceId":"2D227FB9C6D1138E1769DFE648589478ADCDEF4B","kind":"videoinput","label":"Noah’s iPhone Desk View Camera","groupId":""}
]

Safari Desktop:

[
  {"deviceId":"52ABD94C026B20C3FF3AF37F701E156A1BE7557A","kind":"audioinput","label":"MacBook Pro Microphone","groupId":"082C98394E90C47939E93C4A521FF1E982B9C215"},
  {"deviceId":"3CD54FEBE4DEFCBE248BFD371AD7D1CEED8D417E","kind":"audioinput","label":"BlackHole 16ch","groupId":"F71A04BCA6C2953330B04D6A356896A85DC10F8B"},
  {"deviceId":"279BC0FB9937E89F18F1A04DFA531855FFE2F8DF","kind":"audioinput","label":"XONE 96 USB 1","groupId":"9A76BF4CBE512A38ABC52BA057DDFA3A8B6AA31A"},
  {"deviceId":"F5AEE340A817CCE0D3687ECAE87B0572CD2004B5","kind":"audioinput","label":"Noah’s iPhone Microphone","groupId":"AA5084E4581D1676318EB719F7C8A57951D19576"},
  {"deviceId":"99C9D3E03D55E4E77505F6F1262951F7EC63D8AF","kind":"videoinput","label":"FaceTime HD Camera","groupId":""},
  {"deviceId":"8A5CF3B9CA0470C0F011F520A3E95B25A8A3A5DE","kind":"videoinput","label":"OBS Virtual Camera","groupId":""},
  {"deviceId":"0D5F60A9F4499ABE928B9F7FE9AEE1639B8A5AB1","kind":"videoinput","label":"Noah’s iPhone Camera","groupId":""},
  {"deviceId":"8D37863FA87C4452BBC4477D8839B217FD106677","kind":"videoinput","label":"Noah’s iPhone Desk View Camera","groupId":""}
]

The two devices missing are BlackHole 16ch which is a virtual audio device from https://github.com/ExistentialAudio/BlackHole and XONE 96 USB 1 which is an external USB soundcard.

I'll keep digging into if its possible to get access to these devices in Tauri / wry, or Swift / WKWebview, but asking here in case anyone else knows.

Did you get this working somehow?

@nzoschke
Copy link

I just edited above, calling await navigator.mediaDevices.getUserMedia({audio: true,video: false}) is important on safari / webkit. But still some devices are missing under Tauri.

@stolinski
Copy link

I am unable to get this working still in dev mode via pnpm tauri dev.

After updating everything, I am now able to successfully get the prompt on fully built apps.

Is this a limitation that I'll have to work around or should getDisplayMedia permissions prompt correctly in dev.

In dev I see the same NotAllowedError.

[✔] Environment
    - OS: Mac OS 14.4.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.76.0 (07dca489a 2024-02-04)
    ✔ cargo: 1.76.0 (c84b36747 2024-01-18)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.10.0
    - pnpm: 8.14.1
    - npm: 10.2.3
    - bun: 1.0.25

[-] Packages
    - tauri [RUST]: 2.0.0-beta.11
    - tauri-build [RUST]: 2.0.0-beta.9
    - wry [RUST]: 0.37.0
    - tao [RUST]: 0.26.1
    - @tauri-apps/api [NPM]: 2.0.0-beta.5
    - @tauri-apps/cli [NPM]: 2.0.0-beta.9

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Happens even in a brand new project. I'd be interested in seeing what's different in a working example on your end from what's going on with me.

@tarushnagpal
Copy link

Hey, won't this PR break all mac versions between 14.0 to 14.2? we should probably still have that check in but just for versions between these so that the notification does not get suppressed

@pewsheen
Copy link
Contributor

I am unable to get this working still in dev mode via pnpm tauri dev.

After updating everything, I am now able to successfully get the prompt on fully built apps.

Is this a limitation that I'll have to work around or should getDisplayMedia permissions prompt correctly in dev.

In dev I see the same NotAllowedError.

[✔] Environment
    - OS: Mac OS 14.4.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.76.0 (07dca489a 2024-02-04)
    ✔ cargo: 1.76.0 (c84b36747 2024-01-18)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.10.0
    - pnpm: 8.14.1
    - npm: 10.2.3
    - bun: 1.0.25

[-] Packages
    - tauri [RUST]: 2.0.0-beta.11
    - tauri-build [RUST]: 2.0.0-beta.9
    - wry [RUST]: 0.37.0
    - tao [RUST]: 0.26.1
    - @tauri-apps/api [NPM]: 2.0.0-beta.5
    - @tauri-apps/cli [NPM]: 2.0.0-beta.9

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Happens even in a brand new project. I'd be interested in seeing what's different in a working example on your end from what's going on with me.

It's kind of tricky when running tauri dev. It's actually asking the permission for where you call the dev command, like Terminal or vscode

@pewsheen
Copy link
Contributor

Hey, won't this PR break all mac versions between 14.0 to 14.2? we should probably still have that check in but just for versions between these so that the notification does not get suppressed

Yes, it will break those versions. We can do a version check for it, but we don't know the actual affected version yet. What we know is 14.0 is affected, and doesn't know which exact version that Apple changed the behavior back. It would take time to test it.

@stolinski
Copy link

It's kind of tricky when running tauri dev. It's actually asking the permission for where you call the dev command, like Terminal or vscode

That tracks. Is there anyway to get those perms accepted on initialization or is using getDisplayMedia in tauri dev just out of the question.

@tarushnagpal
Copy link

Yes, it will break those versions. We can do a version check for it, but we don't know the actual affected version yet. What we know is 14.0 is affected, and doesn't know which exact version that Apple changed the behavior back. It would take time to test it.

It would be better to test it rather than knowingly release a Tauri version that would break on some MacOS versions imo 😅

@pewsheen
Copy link
Contributor

It's kind of tricky when running tauri dev. It's actually asking the permission for where you call the dev command, like Terminal or vscode

That tracks. Is there anyway to get those perms accepted on initialization or is using getDisplayMedia in tauri dev just out of the question.

I don't know how it really works under the ground, but from my experience, I can use tauri dev for getDisplayMedia after I grant permission to my vscode or iTerm

@stolinski
Copy link

It's kind of tricky when running tauri dev. It's actually asking the permission for where you call the dev command, like Terminal or vscode

That tracks. Is there anyway to get those perms accepted on initialization or is using getDisplayMedia in tauri dev just out of the question.

I don't know how it really works under the ground, but from my experience, I can use tauri dev for getDisplayMedia after I grant permission to my vscode or iTerm

Did you just add it via the MacOS Perms in system prefs? I've given term and vscode screen recording perms but still no go in dev mode.

@pewsheen
Copy link
Contributor

pewsheen commented Apr 8, 2024

It's kind of tricky when running tauri dev. It's actually asking the permission for where you call the dev command, like Terminal or vscode

That tracks. Is there anyway to get those perms accepted on initialization or is using getDisplayMedia in tauri dev just out of the question.

I don't know how it really works under the ground, but from my experience, I can use tauri dev for getDisplayMedia after I grant permission to my vscode or iTerm

Did you just add it via the MacOS Perms in system prefs? I've given term and vscode screen recording perms but still no go in dev mode.

It turns out they are two different issues tauri-apps/wry#1195

It may work with tauri-beta.12 and below and with macOS 14+ since we revert tauri-apps/wry#1111 at wry-0.38. But with the latest tauri release you'll need to patch Wry as a workaround, like what tauri-apps/wry#1111 does but without version check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📬Proposal
Development

No branches or pull requests