Tau: [BUG]: Incompatibility with firebase_messaging+Android+8.0.0.dev causing

Created on 18 Jan 2021  ·  4Comments  ·  Source: Canardoux/tau

Flutter Sound Version :

flutter_sound_lite 7.5.1+2


Severity

FlutterSoundPlayer doesn't initialized properly and any attempt to play audio will fail.


Platforms you faced the error

  • Android with real device

Describe the bug

When firebase_messaging v8.0.0-dev.14 + background handler is used,
firebase_messaging will instantiate a new FlutterEngine instance and in-turn
GeneratedPluginRegistrant will re-initiate FlutterSound.

FlutterSoundPlayer initialization failed due to "firebase background" flutter engine will receive the "openAudioSessionCompleted" callback instead of the main flutter engine.

https://github.com/FirebaseExtended/flutterfire/blob/firebase_messaging-v8.0.0-dev.14/packages/firebase_messaging/firebase_messaging/android/src/main/java/io/flutter/plugins/firebase/messaging/FlutterFirebaseMessagingBackgroundExecutor.java#L183

image

To Reproduce
Steps to reproduce the behavior:

  1. Checkout https://github.com/ed-fx/flutterfire/tree/flutter_sound_lite_issue_with_firebase_messaging_background/packages/firebase_messaging/firebase_messaging/example
  2. Run the main application

Expected behavior:

  1. The play button is enabled

Current behavior:

  1. The play button is disabled

To make flutter_sound_lite initialized properly,
Comment out
https://github.com/ed-fx/flutterfire/blob/flutter_sound_lite_issue_with_firebase_messaging_background/packages/firebase_messaging/firebase_messaging/example/lib/main.dart#L51


Logs

When FirebaseMessaging.onBackgroundHandler NOT set:

Launching lib/main.dart on ONEPLUS A6003 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Waiting for ONEPLUS A6003 to report its views...
Debug service listening on ws://127.0.0.1:62559/m2vI3VkCIKQ=/ws
Syncing files to device ONEPLUS A6003...
I/flutter ( 7627): FS:---> openAudioSession 
I/AudioManager( 7627): In stopBluetoothSco(), calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7627): In setBluetoothScoOn(), on: false, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7627): In setSpeakerphoneOn(), on: true, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7627): In setSpeakerphoneOn(), on: true, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7627): In setBluetoothScoOn(), on: false, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7627): In stopBluetoothSco(), calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7627): In setMode(), mode: 0, calling application: io.flutter.plugins.firebase.messaging.example
I/flutter ( 7627): FS:---> channelMethodCallHandler : openAudioSessionCompleted
I/flutter ( 7627): FS:<--- channelMethodCallHandler : openAudioSessionCompleted
I/flutter ( 7627): FS:<--- openAudioSession 
I/flutter ( 7627): FCM Token: dc90t8cjQV6Nb-QRZQIwVD:APA91bFXI9lcP8hkHg7u5JmZtS-W-Uw-3ixwXDcvnGLqA1B7L27fD0CTZ0h9hAXLHN8DFNqpJ46fRos8PhP2nXd3SEsAnx3MmwOTFI1HCBe4yKUZWevfSAWbbdAV3C3_8apARD-xYG1O

When FirebaseMessaging.onBackgroundHandler set:

Launching lib/main.dart on ONEPLUS A6003 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Waiting for ONEPLUS A6003 to report its views...
Debug service listening on ws://127.0.0.1:62222/johdThS6cBQ=/ws
Syncing files to device ONEPLUS A6003...
I/FLTFireBGExecutor( 7317): Creating background FlutterEngine instance, with args: [--start-paused, --enable-dart-profiling]
I/FLTFireMsgService( 7317): FlutterFirebaseMessagingBackgroundService started!
I/flutter ( 7317): FS:---> openAudioSession 
I/AudioManager( 7317): In stopBluetoothSco(), calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7317): In setBluetoothScoOn(), on: false, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7317): In setSpeakerphoneOn(), on: true, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7317): In setSpeakerphoneOn(), on: true, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7317): In setBluetoothScoOn(), on: false, calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7317): In stopBluetoothSco(), calling application: io.flutter.plugins.firebase.messaging.example
I/AudioManager( 7317): In setMode(), mode: 0, calling application: io.flutter.plugins.firebase.messaging.example
I/flutter ( 7317): FS:<--- openAudioSession 
I/flutter ( 7317): FCM Token: dc90t8cjQV6Nb-QRZQIwVD:APA91bFXI9lcP8hkHg7u5JmZtS-W-Uw-3ixwXDcvnGLqA1B7L27fD0CTZ0h9hAXLHN8DFNqpJ46fRos8PhP2nXd3SEsAnx3MmwOTFI1HCBe4yKUZWevfSAWbbdAV3C3_8apARD-xYG1O

bug Done

All 4 comments

Houaw! This is a Problem Report really correctly filled.
You even posted your App so that I can reproduce your problem 👍 .

I am going to look to it soon (a few days ?).
I am actually overloaded, and I need to close some open tasks before opening a new one.

Thank you for your help. You are definitely contributing for a better τ. 🥇

Hi @Larpoux

https://github.com/Canardoux/tau/pull/595
This is a pull requests that works for my use case.
Please have a look if this is acceptable for all other use cases.

Hi @ed-fx ,

Flutter Sound 7.5.2 is released with your fix.
Thank you again for your contribution :

You saved me at least 1 week (probably more) of very hard debugging .
And spare time is something very precious that I unfortunately do not have.

🥇

Thanks @Larpoux for a swift release!

Was this page helpful?
0 / 5 - 0 ratings