just_audio
just_audio copied to clipboard
The app crashes when the SD card is removed or unmounted while playing on Android device.
Same problem as below. https://stackoverflow.com/questions/71305565/how-can-i-prevent-the-app-from-crashing-when-i-remove-the-sd-card-while-playing
Which API doesn't behave as documented, and how does it misbehave? No error occurs with a specific API, and the app crashes when the SD card is removed or unmounted while playing a track saved on the SD card.
Minimal reproduction project I modified the example of just_audio_background. https://github.com/takuo3/just_audio
To Reproduce (i.e. user steps, not code)
Debug just_audio / just_audio_background / example in the following repository. https://github.com/takuo3/just_audio The device can be either a simulator or an actual device, but please insert an external SD card in advance.
1.Launch the app and debug print will show the path can be available.
I/flutter ( 4667): externalStoragePath: /storage/emulated/0/Android/data/com.ryanheise.just_audio_example/files / index : 0
I/flutter ( 4667): externalStoragePath: /storage/0DFE-0903/Android/data/com.ryanheise.just_audio_example/files / index : 1
2.Rename any mp3 file to test.mp3 and copy the file in the path of the SD card.
3.Edit the index of the following directories variable to the index of the path of the external SD card if necessary. By default, the app looks at the last index path. https://github.com/takuo3/just_audio/blob/89b745200b06c7af8ef6ea121d2ec2aec13817e1/just_audio_background/example/lib/main.dart#L66
4.Launch the app again and A Salute To Head-Scratching Science Play and unmount or remove the SD card and the app will crash. (If you want to unmount, please unmount from the Settings> Storage screen.)
Error messages The error message could not be confirmed on the Flutter platform.
We got the following error in adb logcat.
03-01 18:58:00.091 1518 1860 V MediaSessionRecord: Removing dead callback in pushSessionDestroyed, this=com.ryanheise.just_audio_example/media-session (userId=0), callback package=com.ryanheise.just_audio_example, exception=android.os.DeadObjectException
I Added the log when the problem occurs. https://pastebin.com/n5qgEejD The start and end events are as follows. 03-01 18:57:58.914 / SD card unmounted 03-01 18:58:01.095 / App crashes.
Expected behavior App does not crash.
Desktop (please complete the following information):
- OS: MacOS 12.1 (Apple silicon)
Smartphone (please complete the following information):
- actual device Moto g31(Android11) OPPO Reno A(Android9)
- simulator Pixel3 API28 (arm64 image)
Flutter SDK version Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git Framework • revision c860cba910 (4 days ago) • 2022-03-25 00:23:12 -0500 Engine • revision 57d3bac3dd Tools • Dart 2.16.2 • DevTools 2.9.2
insert output of "flutter doctor" here [✓] Flutter (Channel stable, 2.10.4, on macOS 12.1 21C52 darwin-arm, locale ja-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.61.2) [✓] Connected device (5 available) [✓] HTTP Host Availability
Thanks for reporting. I don't have a way to test sd card issues, but I don't see anything helpful in the logcat. You can get more information about a crash by capturing the bug this way:
https://developer.android.com/studio/debug/bug-report
Otherwise, it may be a matter of using the debugger in Android Studio on the Java code and breaking on all exceptions, or else manually inserting println
statements into the Java code to see where it gets up to before it crashes, if indeed it is crashing within audio_service (that is something I can't really see for sure from your logs).