-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[expo-av][iOS] - Fix AVAudioSession deactivation #16578
Conversation
After ample discussion, testing and consideration, it makes no sense to constantly disable AudioSession as it is a synchronous and blocking process. There were no regressions in various tests. With this change, pauseAsync() function calls are effectively instant without frame drops. To avoid triggering unnecessary setActive:YES calls, we still set the variable without actually disabling the session. We agreed to go this way and in case of doubt look for another approach in a regression. See #15873 fixes #15873 fixes #5297 fixes #16262 fixes #12613 (even though already closed but never fixed)
@bbarthec here we go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks superb 🎉
Thank you @hirbod for taking care of it and fixing this whole set of issues 👏
I'll release it as soon as the CI goes green 😁
@bbarthec thank you very much, but I basically did nothing big here :D |
Yeah! 🎉 @mnightingale, you're doing amazing job for this package 👏 |
Hey @hirbod, thank you for your awesome work and time to get this one fixed, after updating to the version 11.1.0 I lost my audio on videos, is there something that might be missing on the changes you made? Sorry, my knowledge in Object-C is pretty much none |
@tiagotwistag, the changes we've pushed are most likely not causing issues with audio. import { Audio, InterruptionModeAndroid, InterruptionModeIOS, Video } from 'expo-av';
...
useEffect(() => {
const enableAudio = async () => {
try {
await Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: InterruptionModeIOS.DoNotMix,
playsInSilentModeIOS: true, // this one here
staysActiveInBackground: false,
interruptionModeAndroid: InterruptionModeAndroid.DoNotMix,
shouldDuckAndroid: false,
});
} catch {}
};
enableAudio();
}, []); |
@hirbod Yeah you were right I had the wrong value at interruptionModeIOS for some reason I left the android one over there, it does indeed works if properly configured, sorry for that and thanks for the time 👏 |
@tiagotwistag you did have a wrong value (old value) because the values changed in v11 :D. I guess you had v10 values. This one: |
I confirm that the delay after pausing the video is no longer existing. Thank you very much for your work |
Why
After ample discussion, testing and consideration, it makes no sense to constantly disable AudioSession as it is a synchronous and blocking process.
There were no regressions in various tests. With this change, pauseAsync() function calls are effectively instant without frame drops.
To avoid triggering unnecessary setActive:YES calls, we still set the variable without actually disabling the session.
We agreed to go this way and in case of doubt look for another approach in a regression.
See #15873
fixes #15873
fixes #5297
fixes #16262
fixes #12613 (even though already closed but never fixed)
How
We're not going to disable the AudioSession anymore, because it's not needed. This make expo-av behave like almost all other apps that work with video and audio (thus making pausing videos fast and non blocking)
Test Plan
Tested in Simulator and on two real devices running iOS 14 and iOS 15.
Checklist
expo build
(eg: updated@expo/xdl
).expo prebuild
& EAS Build (eg: updated a module plugin).