Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
850 stars 553 forks source link

[BUG]: MissingPluginException(No implementation found for method resetPlugin on channel xyz.canardoux.flutter_sound_player) #1039

Open bcaspe opened 1 month ago

bcaspe commented 1 month ago

Flutter Sound Version : 9.4.11

Full ├── flutter_sound 9.4.11 │ ├── flutter_sound_platform_interface 9.4.11 │ ├── flutter_sound_web 9.4.11 │ │ ├── flutter_sound_platform_interface...

Severity

It does not crash the app fatally, but prevents sound from playing, which is a bad user experience.

Platforms you faced the error


Describe the bug A clear and concise description of what the bug is. MissingPluginException(No implementation found for method resetPlugin on channel xyz.canardoux.flutter_sound_player)

To Reproduce I am not sure the steps to reproduce the bug. I am not experiencing it on my device or on the emulator, but I have users (on newer android phones) who experience the issue when initializing flutter sound

Logs!!!!

Unfortunately, as I can't reproduce the bug on a device I control, it's very difficult to get the logs. It appears that when flutter sound is opened, it tries to call resetPlugin, but it is not finding the method in the android specific code. This doesn't happen all the time, so any help is appreciated in zeroing in on where the bug might be.


Larpoux commented 1 month ago

Thank you @bcaspe for this very clear bug report. I am going to look to this bug today. Reset plugin() has no utility on a release version of the app. The only goal of this function is to reset the plugin when the developer does a hot reload.

Larpoux commented 1 month ago

@bcaspe : what is your project ?

bcaspe commented 1 month ago

@bcaspe : what is your project ?

  • Is it an App that you master the build
  • Or it is a Plugin that you offer and on which others developers depend for their own build ?

This is an app that I master, not a plugin.

Larpoux commented 1 month ago

I am very surprised : the exception seems to be thrown by flutter_sound_web. This module should not be used under Android.

Do you do something special with Flutter Web ? I am going for lunch, now and I will continue to work on this bug this after noon.

bcaspe commented 1 month ago

Thank you @bcaspe for this very clear bug report. I am going to look to this bug today. Reset plugin() has no utility on a release version of the app. The only goal of this function is to reset the plugin when the developer does a hot reload.

yeah, I was thinking of adding a check to kDebugMode on line 518 of flutter_sound_player: if (_reStarted && kDebugMode) { // Perhaps a Hot Restart ? We must reset the plugin _logger.d('Resetting flutter_sound Player Plugin'); _reStarted = false; await FlutterSoundPlayerPlatform.instance.resetPlugin(this); }

bcaspe commented 1 month ago

I am very surprised : the exception seems to be thrown by flutter_sound_web. This module should not be used under Android.

Do you do something special with Flutter Web ? I am going for lunch, now and I will continue to work on this bug this after noon.

I am only using android and ios builds, not a web build...

Larpoux commented 1 month ago

Unfortunately, resetPlugin() is the first verb used on flutter sound. I can ignore any exception for this call, but I gess that we will have same errors, after, when we will call other functions.

bcaspe commented 1 month ago

I couldn't find the android implementation of resetplugin in the flutter sound package though. Is it actually implemented?

On Wed, May 29, 2024, 12:59 Larpoux @.***> wrote:

Unfortunately, resetPlugin() is the first verb used on flutter sound. I can ignore any exception for this call, but I gess that we will have same errors, after, when we will call other functions.

— Reply to this email directly, view it on GitHub https://github.com/Canardoux/flutter_sound/issues/1039#issuecomment-2137024104, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAETNIU6MEB3DDLPMSV3OZ3ZEWRIXAVCNFSM6AAAAABIOGXZPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZXGAZDIMJQGQ . You are receiving this because you were mentioned.Message ID: @.***>

Larpoux commented 1 month ago

I am very surprised : the exception seems to be thrown by flutter_sound_web. This module should not be used under Android.

Do you do something special with Flutter Web ? I am going for lunch, now and I will continue to work on this bug this after noon.

bcaspe commented 1 month ago

I can privately send you the code I'm using to call open flutter sound if that helps.

On Wed, May 29, 2024, 13:03 Larpoux @.***> wrote:

I am very surprised : the exception seems to be thrown by flutter_sound_web. This module should not be used under Android.

Do you do something special with Flutter Web ? I am going for lunch, now and I will continue to work on this bug this after noon.

— Reply to this email directly, view it on GitHub https://github.com/Canardoux/flutter_sound/issues/1039#issuecomment-2137034853, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAETNISYYW6U4SB7KI4XA23ZEWRYXAVCNFSM6AAAAABIOGXZPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZXGAZTIOBVGM . You are receiving this because you were mentioned.Message ID: @.***>

Larpoux commented 1 month ago

Not now. Perhaps later if I need. Maybe I will try your fix if I don’t find. But there is a probability that we will have the same problem with the following next call to the plugin.

very often, when a bug is sometimes but not always, this is a problem with asynchronism. Perhaps a await missing somewhere.

Larpoux commented 1 month ago

The implementation of resetPlugin() is inside flutter_sound_platform_interface for iOS and Android and is not implemented for FlutterWeb.

It seems that your app thinks it is a FlutterWeb App.

Larpoux commented 1 month ago

@bcaspe : I released a new Flutter Sound version 9.4.12. I added the test that you suggested to skip the call to resetPlugin() when in Release mode.

But I think that this fix is not good, because we still may have the same problem in Debug mode, and perhaps the problem will also occur in the following call to Flutter Sound API in Release mode.

I have no time to spend on Flutter Sound maintenance, so I just cross my fingers. I keep this issue Open and I am waiting for your feedback to close it.

bcaspe commented 1 month ago

ok. Thanks. I'll update and release and see if I'm still getting the exception

bcaspe commented 3 weeks ago

Interestingly, now the exception is: MissingPluginException(No implementation found for method openPlayer on channel xyz.canardoux.flutter_sound_player)

So this seems more like some kind of async error as you said. Something needs to be initialized that is not...

Larpoux commented 3 weeks ago

I can privately send you the code I'm using to call open flutter sound if that helps.

Yes, it could help. My email is larpoux<at>gmail.com

Larpoux commented 3 weeks ago

I don't remember if you told me if you play with Isolates or not ?

bcaspe commented 3 weeks ago

I don't remember if you told me if you play with Isolates or not ?

I am not using isolates.

bcaspe commented 3 weeks ago

I can privately send you the code I'm using to call open flutter sound if that helps.

Yes, it could help. My email is larpoux<at>gmail.com

I have moved init flutter sound later in the process to right before I need to play the sound. (it was happening during main execution) so maybe that will help as not everything was set up. My user reports that the audio that was crashing before is not crashing now, so finger's crossed that it is fixed.