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
To Reproduce
Steps to reproduce the behavior:
Error messages
Application went crashed without any additional information and error message.
Expected behavior
Screenshots
No screenshot available
Runtime Environment :
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!
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.
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.