Which API doesn't behave as documented, and how does it misbehave?
Releasing Exoplayer instance from dipose method in AudioPlayer.java is causing ANR:
com.google.android.exoplayer2.ExoPlayerImplInternal.waitUninterruptibly
The above way would still throw some error, but we can handle the error gracefully instead of throwing ANR.
Minimal reproduction project
Happens on production devices, don't have exact reproduction steps for it. Affects around 30+ users per month.
To Reproduce (i.e. user steps, not code)
Might happen when exiting/disposing the audio player instance while playing.
Error messages
Here's the stack track of users from production track who are facing this ANR
at java.lang.Object.wait (Native method)
at java.lang.Object.wait (Object.java:386)
at com.google.android.exoplayer2.ExoPlayerImplInternal.waitUninterruptibly (ExoPlayerImplInternal.java:669)
at com.google.android.exoplayer2.ExoPlayerImplInternal.release (ExoPlayerImplInternal.java:436)
at com.google.android.exoplayer2.ExoPlayerImpl.release (ExoPlayerImpl.java:989)
at com.ryanheise.just_audio.AudioPlayer.dispose (AudioPlayer.java:989)
at com.ryanheise.just_audio.MainMethodCallHandler.onMethodCall (MainMethodCallHandler.java:45)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage (MethodChannel.java:258)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler (DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0 (DartMessenger.java:322)
at io.flutter.embedding.engine.dart.DartMessenger.$r8$lambda$2j2MERcK825A5j1fv5sZ7xB2Iuo (DartMessenger.java)
at io.flutter.embedding.engine.dart.DartMessenger$$InternalSyntheticLambda$0$ceffc6bae7d364cb48afaf1aaebd60bf9050360d0efb9035ebc54f0851df0a05$0.run (DartMessenger.java:12)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:233)
at android.os.Looper.loop (Looper.java:344)
at android.app.ActivityThread.main (ActivityThread.java:8212)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1034)
Expected behavior
ANR should not be happening, if some error is there it should be handled and if required exit the application.
Screenshots
No screenshots.
Desktop (please complete the following information):
OS: MacOS
Chrome
Smartphone (please complete the following information):
realme RMX2030 (realme 5i)
Android 10 (It is faced by all android versions though)
just_audio_version
0.9.28
Flutter SDK version
3.7.12
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.12, on macOS 13.1 22C65 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.84.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!
Since you haven't provided a reproduction project, I can't test this. However, perhaps you would consider testing that workaround within your own app and submitting a PR?
Which API doesn't behave as documented, and how does it misbehave? Releasing Exoplayer instance from dipose method in AudioPlayer.java is causing ANR: com.google.android.exoplayer2.ExoPlayerImplInternal.waitUninterruptibly
The ANR seems to be an existing filed issue (https://github.com/google/ExoPlayer/issues/4352)
One way to deal with the ANR is also mentioned in one of the comments: https://github.com/google/ExoPlayer/issues/4352#issuecomment-471476612
The above way would still throw some error, but we can handle the error gracefully instead of throwing ANR.
Minimal reproduction project Happens on production devices, don't have exact reproduction steps for it. Affects around 30+ users per month.
To Reproduce (i.e. user steps, not code) Might happen when exiting/disposing the audio player instance while playing.
Error messages Here's the stack track of users from production track who are facing this ANR
Expected behavior ANR should not be happening, if some error is there it should be handled and if required exit the application.
Screenshots No screenshots.
Desktop (please complete the following information):
Smartphone (please complete the following information): realme RMX2030 (realme 5i) Android 10 (It is faced by all android versions though)
just_audio_version 0.9.28
Flutter SDK version 3.7.12
Additional context No additional context.