ryanheise / just_audio

Audio Player
1.04k stars 672 forks source link

No implementation found for plugin dispose method mainly on Android TV devices #1179

Open under3415 opened 9 months ago

under3415 commented 9 months ago

Which API doesn't behave as documented, and how does it misbehave?

Below crash is reported by Firebase Crashlytics in production from some, mainly Android TV devices. I cannot replicate.

MissingPluginException: No implementation found for method dispose on channel com.ryanheise.just_audio.methods.

Minimal reproduction project I cannot replicate this, it is happening very infrequently in prod, mainly on Android TV devices as explained on SO.

To Reproduce (i.e. user steps, not code) Cannot reproduce. My dispose code looks like this. Despite try/catch block I am getting unhandled error

 @override
  dispose() {
    try {
      _timer?.cancel(); //stop the timer
      WidgetsBinding.instance.removeObserver(this);
      _controller.dispose(); //disp[ose controller playing animations
      WakelockPlus.disable(); //disable wake lock
      _soundPlayer.dispose(); //dispose just_audio player #1
      _musicPlayer.dispose(); //dispose just_audio player #2
    } catch (ex, st) {
      FirebaseCrashlytics.instance
          .recordError(ex, st, reason: 'workoutDispose');
    }
    super.dispose();
  }

Error messages

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: MissingPluginException(No implementation found for method dispose on channel com.ryanheise.just_audio.methods.36090486-58da-44d3-9ca0-f1f29e063203)
#00 pc 0x891c6f com.example.app (MethodChannel._invokeMethod [platform_channel.dart:320]) (BuildId: 3aa6f915bd6b94591e48b711e1f3fe18)
#01 pc 0x8a201f com.example.app (MethodChannelAudioPlayer.dispose [method_channel_just_audio.dart:174]) (BuildId: 3aa6f915bd6b94591e48b711e1f3fe18)
#02 pc 0x87400f com.example.app (AudioPlayer._disposePlatform [just_audio.dart:1494]) (BuildId: 3aa6f915bd6b94591e48b711e1f3fe18)
#03 pc 0x888937 com.example.app (AudioPlayer.dispose [just_audio.dart:1204]) (BuildId: 3aa6f915bd6b94591e48b711e1f3fe18)

Expected behavior No crash

Screenshots N/A

Desktop (please complete the following information): N/A

Smartphone (please complete the following information):

Flutter SDK version

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.22631.3007], locale en-NZ)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Android Studio (version 2023.1)
[√] VS Code (version 1.85.2)

Additional context N/A

under3415 commented 8 months ago

More crashes reported by Crashlytics:

image

ryanheise commented 8 months ago

Looking at your SO question, do you know whether it is the first or second player that's crashing? If the second, it may be a bug in just audio. If the first it may be something to do with other components of your app. I can't look into that without a reproduction project.

under3415 commented 7 months ago

I cannot tell, the error only has plugin code references, not my own code.

ryanheise commented 7 months ago

Then I don't have any way to investigate this.