hirbod / react-native-volume-manager

React Native module which adds the ability to change the system volume on iOS and Android, listen to volume changes and supress the native volume UI to build your own volume slider or UX. It can listen to iOS mute switch and ringer mode changes on Android (and let you set the ringer mode)
MIT License
244 stars 18 forks source link

Calling `getVolume` causes a crash on iOS on new architecture, React Native 0.76 #43

Open hrastnik opened 2 weeks ago

hrastnik commented 2 weeks ago

Calling getVolume causes a crash on iOS with the following error observed in XCode logs:

AVAudioSession_iOS.mm:2386  Failed to set category, error: -50

Steps to reproduce:

  1. Initialize a new React Native v0.76 project
  2. Install react-native-volume-manager
  3. Run getVolume

The app crashes.

The following snippet is enough to confirm it crashes when calling getVolume

import React from 'react';
import {Button, View} from 'react-native';
import {getVolume} from 'react-native-volume-manager';

export default function App() {
  return (
    <View style={{flex: 1, justifyContent: 'center'}}>
      <Button
        title="Get volume"
        onPress={async () => {
          const volume = await getVolume();
          console.log('Volume:', volume);
        }}></Button>
    </View>
  );
}
hirbod commented 2 weeks ago

This library is not compatible with the new arch yet.

hrastnik commented 2 weeks ago

@hirbod Are you planning to add support for the new architecture soon?

hirbod commented 2 weeks ago

I am planning since 2022, but no-one stepped in so far to help, I don't have any knowledge. I have hopes that expo-audio might deprecate my library soon though.

marcosinigaglia commented 1 week ago

Hi @hirbod , we are finishing to migrate our ble library with RN 0.76 (https://github.com/innoveit/react-native-ble-manager/pull/1285), you can take a look in the changes to support this lib. I can help if you have problems.

hrastnik commented 1 week ago

@hirbod I'd be happy to help. And for the last few days I've been trying to get the library to work with the new architecture while remaining backwards compatible.

So far I have a solution for iOS, but it's kind of complex when I try to keep it backward compatible. Would you be ok with having a breaking change and forcing RN76 users to use the new library version and <RN76 users would stay on the current version?

hirbod commented 1 week ago

@hrastnik absolutely. I was planning to make a final release for <RN76 to fix the Android crash and going forward, we can force v2 for RN76+