jamsch / expo-speech-recognition

Speech Recognition for React Native Expo projects
MIT License
128 stars 11 forks source link

Requesting permissions makes the app crash on a physical device. (dev client) #24

Closed thebiltheory closed 2 months ago

thebiltheory commented 2 months ago

Perhaps I'm doing something wrong but I made sure to follow the doc.

The app crashes on a physical device every time I run requestPermissionsAsync.

Here is a simple implementation of a screen. I stripped everything from the screen to isolate the issue.

Screenshot 2024-09-25 at 6 43 14 PM

Permissions are also well configured in app.json.

Am I missing something?

thebiltheory commented 2 months ago

For what it's worth. It is also crashing when using requestPermissionsAsync from Audio.

import { Audio } from "expo-av";
...

  useEffect(() => {
    async function requestPermissions() {
      console.log("⁉️ Requesting permissions");

      const result = await Audio.requestPermissionsAsync();

      console.log("Request permissions result", result);

      if (!result.granted) {
        console.warn("Permissions not granted", result);
        return;
      }
    }

    requestPermissions();
  }, []);
jamsch commented 2 months ago

Hey @thebiltheory!, here's a few things you might want to check:

If those don't work, could you provide me the following:

thebiltheory commented 2 months ago

Hey @jamsch, Thanks for the fast response!!

Wrapping it in a try/catch doesn't work. The app closes immediately. It's really hard to tell what causes the issue.

I'm running ios 18 tho.

EDIT: Ran an iPhone 16 simulator with ios18

[TCC] This app has crashed because it attempted to access
privacy-sensitive data without a usage description.  The app's
Info.plist must contain an NSMicrophoneUsageDescription key with
a string value explaining to the user how the app uses this
data.
jamsch commented 2 months ago

@thebiltheory That looks like the app wasn't built with the config plugin. Have you added that in to your app.json? You can copy the contents from the installation step 2 on the readme. It's also likely why expo-av wasn't working for you either. You also may need to run a fresh prebuild (npx expo prebuild --clean) to regenerate the android/iOS folders with the config from app.json.

thebiltheory commented 2 months ago

@jamsch I did! I have also prebuild the app many times

It was working with ios17 tho.

Screenshot 2024-09-26 at 9 50 55 AM Screenshot 2024-09-26 at 9 51 18 AM
jamsch commented 2 months ago

@thebiltheory Very strange. Just to confirm when you run the prebuild, does your app include the permissions in ios/[app_name]/Info.plist? (also small nit: you've got expo-asset there twice)

thebiltheory commented 2 months ago

I feel stup*d.😂 Removing expo-asset did the trick!

Thanks for being my rubber duck @jamsch. image

Take aways:

  1. Granularly double check configuration.
  2. Be more cautious during the rebase of a branch.

Also. Thank you for this library.

thebiltheory commented 2 months ago

Fixed.