tauri: [bug] audio recording via getUserMedia permission error
Describe the bug
This is only an issue in production build and when the app is notarized.
It throws error when I call mediaDevices.getUserMedia({audio: true}):
The request is not allowed by the user agent or the platform in the current context
Reproduction
here’s the repo I created using create-tauri-app: https://github.com/egoist-bot/tauri-audio-bug
here’s the changes: https://github.com/egoist-bot/tauri-audio-bug/commit/b580280c151259111e3c5bf67d324a2cd2a8e2c6 i already added plist.info and it still doesn’t work
see build.mjs to configure all the env variables needed for the build, then run node build.mjs
Expected behavior
should start recording audio
Platform and versions
[✔] Environment
- OS: Mac OS 14.1.1 X64
✔ Xcode Command Line Tools: installed
✔ rustc: 1.73.0 (cc66ad468 2023-10-03)
✔ cargo: 1.73.0 (9c4383fb5 2023-08-26)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 18.16.0
- pnpm: 8.10.0
- yarn: 1.22.19
- npm: 9.5.1
- bun: 1.0.11
[-] Packages
- tauri [RUST]: 1.5.2
- tauri-build [RUST]: 1.5.0
- wry [RUST]: 0.24.6
- tao [RUST]: 0.16.5
- @tauri-apps/api [NPM]: 1.5.1
- @tauri-apps/cli [NPM]: 1.5.6
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:1420/
- bundler: Vite
Stack trace
No response
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (5 by maintainers)
Just stumbled upon this thread and after a long time I realised that you need both the entitlements file and
Info.plistfor example (both insrc-tauri):Entitlements.plist:Info.plist:and you need
"Entitlements.plist"inbundle->macOS->entitlementsin yourtauri.conf.json(as described here).Last idea, can you try moving the sandbox properties into a seperate entitlements file like this one? https://github.com/tauri-apps/tauri/blob/1.x/examples/updater/entitlements.plist (needs to be added to tauri.conf here https://github.com/tauri-apps/tauri/blob/1.x/examples/updater/src-tauri/tauri.conf.json#L36