[SDK 45] [expo-av] Unmounted Video plays after switching the app to foreground
See original GitHub issueSummary
Starting from SDK 45, expo-av@11.2.3
doesn’t destroy unmounted Video components and resumes their playback after switching the app from background to foreground.
This issue does not occur in SDK 44 with expo-av@10.2.1
, although I don’t think there’s a problem with AV. Possibly it’s something within expo-core-modules
?
Here’s a quick recording that showcases this bug (listen with audio):
https://user-images.githubusercontent.com/6288237/168903942-b0abf33c-0387-4e86-a31c-89371d42d082.mp4
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
bare
What platform(s) does this occur on?
iOS
SDK Version (managed workflow only)
45
Environment
expo-env-info 1.0.3 environment info:
System:
OS: macOS 12.3.1
Shell: 3.3.1 - /opt/homebrew/bin/fish
Binaries:
Node: 14.18.3 - ~/.local/share/nvm/v14.18.3/bin/node
Yarn: 3.2.0 - /opt/homebrew/bin/yarn
npm: 8.5.4 - ~/.local/share/nvm/v14.18.3/bin/npm
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
npmPackages:
expo: ^45.0.4 => 45.0.4
react: 17.0.2 => 17.0.2
react-native: 0.68.0 => 0.68.0
npmGlobalPackages:
expo-cli: 5.4.3
Expo Workflow: bare
Reproducible demo
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:15 (9 by maintainers)
Top Results From Across the Web
AV - Expo Documentation
The Audio.Sound objects and Video components share a unified imperative API for media playback. Note that for Video , all of these operations...
Read more >Newest 'expo-av' Questions - Stack Overflow
I am developing a recording app with expo av. I would like to save the recording in case the user closes the app...
Read more >[Solved]-How to alert something when the video ends on expo ...
Coding example for the question How to alert something when the video ends on expo-video-player on react native?-React Native.
Read more >@expo/config-plugins | Yarn - Package Manager
This is the log of notable changes to the Expo client that are developer-facing. Package-specific changes not released in any SDK will be...
Read more >How To Play Video With React Native And Expo - Medium
Our goals are to starting React Native App from scratch, play an ... to run our App: A mobile phone with Expo (SDK...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As for when the audio starts playing when the app switches from foreground to background, I think it lies with the Reanimated being able to take a “snapshot” of the view like @barthap mentioned.
My plan is to put together a test app paired with the Xcode debugger to see what is going on.
@hirbod I think you might be onto it. I agree with you that the strong reference would prevent the video from entirely unloading and thereby prevent the video from executing its end of lifecycle events.
My guess is that when we put all of Expo Video’s functionality on the Main thread SWM’s LayoutAnimation is somehow able to get ahold of and keep a strong reference to the Expo Video.
I believe once SWM gets this fixed we should be OK. Though, I would like the Expo Video to stop playing sound and unlist its event listeners when it unmounts (or if LayoutAnimation is preventing unmounting at least when we explicitly call
unloadAsync()
).I’ll try to whip up a solution if I get a chance.
Also, I noticed some issues around Expo Video’s pausing and playing functionality. It doesn’t really cause the UI to freeze like previously but I’ve noticed it skipped time when pausing/playing. I don’t remember this exactly being an issue with Expo 44 with my patch but it seems to be apparent in the latest 45. I’ll put a more detailed report of my findings if I still see this happening. Just putting this out there here in case any of you have experienced the same thing.