Audio_service: google_sign_in cannot be used with audio_service

Created on 27 Jan 2021  Â·  4Comments  Â·  Source: ryanheise/audio_service

Which API doesn't behave as documented, and how does it misbehave?
Seems like AudioService.disconnect() is not actually disconnecting audio service from app.

Minimal reproduction project

  1. You can reproduce this bug by implementing Google Sign In in 'The example'.

To Reproduce
Steps to reproduce the behavior:

  1. Go to The example
  2. Implement Google Sign In
  3. Start any audio with Audio Service background task
  4. Try to Google Sign In
  5. App will crashed after you continue by entering your google sign in credential
  6. Now try to Stop audio Service or Disconnect audio service before you press google sign in button, in this case app is not gonna crash but nothing is gonna happen after google sign in dialog disappear.
  7. When I tried google sign in without Playing any audio from app then it's gonna work but once I play any audio then after I am not able to google sign in.

Error messages

Application went crashed without any additional information and error message. 

Expected behavior

  1. App should not be crashed if I tried to google sign in after playing any audio.

Screenshots
No screenshot available

Runtime Environment :

  • Device: iPhone XS Max
  • OS: 14.3

Flutter SDK version

[✓] Flutter (Channel stable, 1.22.4, on Mac OS X 10.14.6 18G103 darwin-x64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.52.1)
[✓] Connected device (1 available)

• No issues found!
1 backlog bug

Most helpful comment

Good news; I figured out what was going on. The issue wasn't with AudioService, but instead with Flutter's Google Sign In. It was using a particular _accountRequest variable that was not globally or statically set, meaning it was unpredictably referenced. Any fun framework, audio_service included, could've pushed its address to the side randomly, and it would've invoked a crash or a hang.

To fix it, in your yaml file, use this for google_sign_in:

google_sign_in: #^4.5.9
git:
url: git://github.com/sanekyy/plugins.git
ref: ios-fix-sign-in
path: packages/google_sign_in/google_sign_in

It's a temporary fix, as it was created 5 days before the time of writing this, but it fixed this issue for me.

All 4 comments

Please provide a minimal reproduction project in section 2, and user steps, not code, in section 3 (that is, please don't ask me to implement something, since section 2 should provide the link to the reproduction project that I can clone and run). In section 1, please elaborate and cross-reference the documentation. It will not qualify as a bug in audio_service unless the disconnect method is not behaving consistently with its documentation. If there is a crash, there should also be an error. It may not be a Flutter error, but it should show in Xcode.

Finally, I have a strong suspicion that this is not a bug in audio_service but rather a bug in google_sign_in. If you disagree, please include enough information in your bug report to make it clear that the fault is with audio_service and not with google_sign_in.

I'm also able to reproduce this bug.

In a nutshell, if audio service is initialized before I attempt to log into a Google Account, then the call to google_sign_in will never return a response, effectively causing the app to forever await for one.

Can be reproduced by creating an app with this example code: https://pub.dev/packages/google_sign_in/example, and also initializing AudioService in its main().

I do not believe it's a bug with google_sign_in because running the example by itself lets me sign in multiple times without issue. That being said, I can't say for sure it's a bug with audio-service either. I believe it might be a bug with the Flutter channel framework itself being unable to handle both of them simultanously.

What I believe might be happening is that the call to AudioService is somehow cancelling a listener to subsequent calls in the Flutter PlatformChannel's _invokeMethod.

Alongside google_sign_in, another call that's not returning a value is this:
flutter: Invoking: com.rmawatson.flutterisolate/control - kill_isolate <-- {"isolate_id":"537e81c8-f8f4-4a2b-b976-03598f9ae30d"} ...

Good news; I figured out what was going on. The issue wasn't with AudioService, but instead with Flutter's Google Sign In. It was using a particular _accountRequest variable that was not globally or statically set, meaning it was unpredictably referenced. Any fun framework, audio_service included, could've pushed its address to the side randomly, and it would've invoked a crash or a hang.

To fix it, in your yaml file, use this for google_sign_in:

google_sign_in: #^4.5.9
git:
url: git://github.com/sanekyy/plugins.git
ref: ios-fix-sign-in
path: packages/google_sign_in/google_sign_in

It's a temporary fix, as it was created 5 days before the time of writing this, but it fixed this issue for me.

Thank you @AlexGarneau
Much appreciated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanheise picture ryanheise  Â·  6Comments

getmmg picture getmmg  Â·  3Comments

suragch picture suragch  Â·  4Comments

MohamedAbdallah-14 picture MohamedAbdallah-14  Â·  7Comments

mrxten picture mrxten  Â·  5Comments