bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.14k stars 3.45k forks source link

macOS asks for permission to use the microphone #13989

Open tsukinoko-kun opened 2 months ago

tsukinoko-kun commented 2 months ago

Bevy version

0.13.2

[Optional] Relevant system information

macOS Sonoma 14.5

MacBook Pro 13" M2

What you did

When I run the game on macOS from the terinal, RustRover and the compiled binary.

What went wrong

It works but macOS asks for microphone permission.

Additional information

Screenshot 2024-06-23 at 15 53 04
mockersf commented 2 months ago

Does this happen with Bevy examples?

tsukinoko-kun commented 2 months ago
Screenshot 2024-06-24 at 01 27 02

I tried volumetric_fog and it happened there too.

mockersf commented 2 months ago

can't reproduce on my Mac

janhohenheim commented 2 months ago

I can remember running into this while running Foxtrot on my macOS, which surprised me. I'll check if I can reproduce this with the given example.

janhohenheim commented 2 months ago

I can confirm I can reproduce the bug. I thought I couldn't at first, but then realized that I already had disallowed my terminal to use the microphone, so no new popup came up. Steps to reproduce:

results in:

image

My machine:

image

From experience, I know that at least Foxtrot asks for the same permission when setting it up as a regular graphical app without running it in the terminal.

janhohenheim commented 2 months ago

Update: I found a relevant thread on Discord from a year ago. Something about permissions being weird when info.plist is missing.

bash commented 2 months ago

I used tccutil to reset the microphone permission for the terminal app. That way the permission prompt shows up again when I run a bevy app (cargo run --example volumetric_fog on main).

By resetting the permissions before running a bevy app I can get the prompt to consistently show up.

For macOS' Terminal the command is tccutil reset Microphone com.apple.Terminal. Alternatively for WezTerm: tccutil reset Microphone com.github.wez.wezterm

bash commented 1 month ago

I managed to narrow this down to the function default_output_device in cpal which gets called via AudioPluginAudioOutput::defaultOutputStream::try_default.

cpal::default_host().default_output_device();
janhohenheim commented 1 month ago

Marking as blocked since this seems like a cpal issue then. Unless we can pass some magic parameters.

benfrankel commented 1 month ago

Is there an upstream issue for this?

EDIT: Yes there is: https://github.com/RustAudio/cpal/issues/901