Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Bug: Audio of another App stops when I close Tooot #499

Closed
DerZyklop opened this issue Dec 2, 2022 · 21 comments
Closed

Bug: Audio of another App stops when I close Tooot #499

DerZyklop opened this issue Dec 2, 2022 · 21 comments

Comments

@DerZyklop
Copy link

DerZyklop commented Dec 2, 2022

Audio stops when I close Tooot. Tested it with these:
Spotify music stops when I close tooot.
Pocket Casts podcasts stop when I close tooot.

I think it is related to the fact that I had watched a video inside tooot previously.

After I close the app tooot completely and restart, the issue was gone.

@DerZyklop
Copy link
Author

It is reproducible on my device. I made a video. If you are interested, tell me. For some reason I cannot post/upload it here.
¯_(ツ)_/¯

@de1acr0ix
Copy link
Contributor

I suspect it is related to my changes in #491. I found setting the audio mode is really tricky after reading Exponent source and Apple document. I will experiment a bit on the combinations.

@xmflsct
Copy link
Member

xmflsct commented Dec 3, 2022

@de1acr0ix no no, this bug is already there for ages. I actually could not figure out why. Though I did not look into Exponent's source much. If you have any findings in there, please share. Thanks!

@de1acr0ix
Copy link
Contributor

de1acr0ix commented Dec 3, 2022

@xmflsct Oh okay. I am feeling this is actually an expo-av bug. Looking through its source it seems to be setting the audio session mode to AVAudioSessionCategorySoloAmbient when app is switched to background. However it does not deactivate the audio session (it never does) and it kinda stops audio playback in other apps. But I still need some more experiments to prove that.

@de1acr0ix
Copy link
Contributor

I do see there is a very similar issue raised for expo-av. It actually mentions the same behavior. I will join the discussion there and see if we can make any progress.

@xmflsct
Copy link
Member

xmflsct commented Dec 3, 2022

@de1acr0ix I am surprised that issue is so new. 😂

@de1acr0ix
Copy link
Contributor

@xmflsct This isn't very new if I am understanding correctly. With expo/expo#16578 expo-av stopped deactivating audio session and I believe that is the time when the problem occurs. It happens in March this year.

@de1acr0ix
Copy link
Contributor

Well I myself can confirm it is the bug of expo-av by debugging tooot on simulator. When it is switched to background its audio session mode is set to AVAudioSessionCategorySoloAmbient without deactivating the session.

@de1acr0ix
Copy link
Contributor

de1acr0ix commented Dec 3, 2022

My comment in expo-av issue expo/expo#19042 (comment). I will try to create a PR there later, probably tomorrow.

@xmflsct
Copy link
Member

xmflsct commented Dec 3, 2022

@de1acr0ix Looking forward! Just read through the linked issue in Expo. If it doesn't work out, I can try https://github.com/hirbod/react-native-volume-manager/ as mentioned.

@canny
Copy link

canny bot commented Dec 3, 2022

This issue has been linked to a Canny post: 现在这个版本又出现了切app会导致正在播放的音乐暂停的bug 🎉

@xmflsct
Copy link
Member

xmflsct commented Dec 4, 2022

#507 fixed the issue, tested through TestFlight. Still yet to try how it works with DuckOthers. cc @de1acr0ix

xmflsct added a commit that referenced this issue Dec 4, 2022
@xmflsct
Copy link
Member

xmflsct commented Dec 4, 2022

Confirm fixed in above PR.

@xmflsct xmflsct closed this as completed Dec 4, 2022
@de1acr0ix
Copy link
Contributor

de1acr0ix commented Dec 5, 2022

#507 fixed the issue, tested through TestFlight. Still yet to try how it works with DuckOthers. cc @de1acr0ix

I don't think DuckOthers works well. According to Apple documentation:

Note that ducking begins when you activate your app’s audio session and ends when you deactivate the session. If you clear this option, activating your session interrupts other audio sessions.

As expo-av never deactivates audio session, the ducked audio never return to its original volume unless we put Tooot to background or close it. This happens even when playback finishes.

@xmflsct
Copy link
Member

xmflsct commented Dec 5, 2022

@de1acr0ix that is right. In this case I can change ducking to DoNotMix. In this case other audio playback will be stopped whenever a video starts playing in tooot. The other audio playback won't be resumed automatically due to lack of ending audio session in expo-av. But at least, closing tooot won't "randomly" stop other audio playback. How does this sound?

@xmflsct xmflsct reopened this Dec 5, 2022
@de1acr0ix
Copy link
Contributor

@xmflsct Even with DuckOthers now closing tooot won’t stop other audio playback as the patch I added should have addressed that issue (which happens regardless the option).

Your proposal does sound better but the behavior needs to be tested. Other audio may still resume after tooot is switched to background.

BTW is there any easier way to test on real iOS device? I have enrolled developer program yesterday but I have to change couple of settings such as bundle id to make it work.

@xmflsct
Copy link
Member

xmflsct commented Dec 5, 2022

@de1acr0ix I wish I knew 😂 I still find the whole app signing confusing, so I would not touch it unless it is broken. But if you are aiming for testing locally only, I believe you can change the signing in Xcode to let it manage everything with your account. Currently the signing is managed by fastlane's match so it shows up as incorrect in Xcode.

Unfortunately the simulator does not work like a real device when I tested this issue in particular, FYI.

xmflsct added a commit that referenced this issue Dec 5, 2022
@xmflsct
Copy link
Member

xmflsct commented Dec 7, 2022

@de1acr0ix have you managed to try out the latest build of v4.6.6? How do you think its behaviour now?

@de1acr0ix
Copy link
Contributor

@de1acr0ix have you managed to try out the latest build of v4.6.6? How do you think its behaviour now?

I just tried that. The audio in Spotify stops when starting playing audio/video and won’t resume thereafter, including switching Tooot to background. So far I think this is best we can get without changing expo-av.

@xmflsct
Copy link
Member

xmflsct commented Dec 8, 2022

@de1acr0ix indeed, until expo-av supports resuming (or stopping the session as you found out), it is the best so far. I will close this ticket then. Thanks again for your help!

@xmflsct xmflsct closed this as completed Dec 8, 2022
@ZerglingGo
Copy link

My tooot is showing this problem again.
Didn't play any video, background music stopped when closing app on activated timeline tab (Home, Global)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants