flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_auth] FlutterView.send called on a detached view

Open flutterfrank opened this issue 6 years ago • 6 comments

Bug report

If I press the back button in Android and then open the app again and login and logout I get the message: D/FirebaseAuth(12979): Notifying id token listeners about a sign-out event. D/FirebaseAuth(12979): Notifying auth state listeners about a sign-out event. D/FlutterNativeView(12979): FlutterView.send called on a detached view, channel=plugins.flutter.io/firebase_auth D/FlutterNativeView(12979): FlutterView.send called on a detached view, channel=plugins.flutter.io/firebase_auth

authStateChanges() is not fired.

Steps to reproduce

Steps to reproduce the behavior:

  1. Use the example firebase_auth app.
  2. Go to SignInPage.
  3. Login with E-Mail and Password and logout and login again and again and again. Everything is fine.
  4. Press back Button and go back in the app to the SignInPage.
  5. If I logout or login I get the message: D/FirebaseAuth(12979): Notifying id token listeners about a sign-out event. D/FirebaseAuth(12979): Notifying auth state listeners about a sign-out event. D/FlutterNativeView(12979): FlutterView.send called on a detached view, channel=plugins.flutter.io/firebase_auth D/FlutterNativeView(12979): FlutterView.send called on a detached view, channel=plugins.flutter.io/firebase_auth

Expected behavior

  1. If I add a listener to authStateChanges() in the the SigninPage I do not get the print anymore after pressing back button and go back in the app. I would expect that it would still work as before pressing the back button.

@override void initState() { super.initState();

_auth.authStateChanges().listen((User user) {
  if (user == null) {
    print('User is currently signed out!');
  } else {
    print('User is signed in!');
  }
});

}

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[√] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.18363.1016], locale de-DE)
 
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[√] Android Studio (version 3.5)
[√] VS Code, 64-bit edition (version 1.48.2)
[√] Connected device (1 available)

• No issues found!

flutterfrank avatar Sep 03 '20 00:09 flutterfrank

Hi @flutterfrank, I tried to replicate the issue using the official firebase_auth plugin example on Stable (1.20.2) but didn't see theFlutterView.send log in the console after following all the steps you mentioned.

log
I/BiChannelGoogleApi(11641): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@75ddb48
W/DynamiteModule(11641): Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseAuth(11641): [FirebaseAuth:] Preparing to create service connection to gms implementation
D/FirebaseAuth(11641): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(11641): Notifying auth state listeners about a sign-out event.
I/BiChannelGoogleApi(11641): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@75ddb48
D/FirebaseAuth(11641): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(11641): Notifying auth state listeners about a sign-out event.
I/BiChannelGoogleApi(11641): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@75ddb48
D/FirebaseAuth(11641): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(11641): Notifying auth state listeners about a sign-out event.
I/BiChannelGoogleApi(11641): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@75ddb48
D/FirebaseAuth(11641): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(11641): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(11641): Notifying auth state listeners about a sign-out event.

Just a quick question, when you say press back button, are you pressing the app bar back or the device back button ? Not that it'll make a difference but just making sure. I tried using both back buttons and didn't see the issue.

flutter doctor -v
[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.2 19C57, locale en-US)
    • Flutter version 1.20.2 at
      /Users/deeptibelsare/Documents/Fluttersdk/flutter
    • Framework revision bbfbf1770c (3 weeks ago), 2020-08-13 08:33:09 -0700
    • Engine revision 9d5b21729f
    • Dart version 2.9.1

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/deeptibelsare/Library/Android/sdk
    • Platform android-30, build-tools 29.0.3
    • ANDROID_HOME = /Users/deeptibelsare/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/deeptibelsare/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit
      https://flutter.dev/docs/get-started/install/macos#android-setup for
      detailed instructions.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.3

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)

 
[✓] Connected device (1 available)   

darshankawar avatar Sep 03 '20 10:09 darshankawar

Hello and thanks for your answer. I close the app, with pressing two times the back button of the phone. Then I reopen the app. Did you close the app or only go back to the startscreen?

flutterfrank avatar Sep 03 '20 10:09 flutterfrank

@flutterfrank Yes tried twice by closing app pressing back button and reopened, logged in, logged out. Didn't see the log. I used Android device 8.1.0

log
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Waiting for SM A260G to report its views...
Debug service listening on ws://127.0.0.1:57689/55kx3EEXbgY=/ws
Syncing files to device SM A260G...
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x888]-format:1
W/mali_winsys(14019): native_window_api_disconnect failed: -19
W/libEGL  (14019): EGLNativeWindowType 0xd3888808 disconnect failed
I/zygote  (14019): Do partial code cache collection, code=30KB, data=24KB
I/zygote  (14019): After code cache collection, code=30KB, data=24KB
I/zygote  (14019): Increasing code cache capacity to 128KB
I/zygote  (14019): Do partial code cache collection, code=62KB, data=52KB
I/zygote  (14019): After code cache collection, code=62KB, data=52KB
I/zygote  (14019): Increasing code cache capacity to 256KB
I/BiChannelGoogleApi(14019): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@325f996
D/FirebaseAuth(14019): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(14019): Notifying auth state listeners about a sign-out event.
I/BiChannelGoogleApi(14019): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@325f996
D/FirebaseAuth(14019): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(14019): Notifying auth state listeners about a sign-out event.
I/BiChannelGoogleApi(14019): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@325f996
D/FirebaseAuth(14019): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(14019): Notifying auth state listeners about a sign-out event.
I/BiChannelGoogleApi(14019): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@325f996
D/FirebaseAuth(14019): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(14019): Notifying auth state listeners about a sign-out event.
W/libEGL  (14019): EGLNativeWindowType 0xd3883808 disconnect failed
W/mali_winsys(14019): native_window_api_disconnect failed: -19
W/libEGL  (14019): EGLNativeWindowType 0xe906b808 disconnect failed
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x960]-format:1
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x888]-format:1
I/Choreographer(14019): Skipped 38 frames!  The application may be doing too much work on its main thread.
I/zygote  (14019): Do full code cache collection, code=125KB, data=100KB
I/zygote  (14019): After code cache collection, code=120KB, data=77KB
I/BiChannelGoogleApi(14019): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@325f996
D/FirebaseAuth(14019): Notifying id token listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying auth state listeners about user ( Yfht5cgkaHVRClWEqyrTZRTNgbz2 ).
D/FirebaseAuth(14019): Notifying id token listeners about a sign-out event.
D/FirebaseAuth(14019): Notifying auth state listeners about a sign-out event.
W/libEGL  (14019): EGLNativeWindowType 0xd5abd008 disconnect failed
W/mali_winsys(14019): native_window_api_disconnect failed: -19
W/libEGL  (14019): EGLNativeWindowType 0xcd2d2008 disconnect failed
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x960]-format:1
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x888]-format:1
I/Choreographer(14019): Skipped 33 frames!  The application may be doing too much work on its main thread.
W/libEGL  (14019): EGLNativeWindowType 0xd38bb008 disconnect failed
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x960]-format:1
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x888]-format:1
E/BpSurfaceComposerClient(14019): Failed to transact (-1)
E/BpSurfaceComposerClient(14019): Failed to transact (-1)
W/libEGL  (14019): EGLNativeWindowType 0xd3b60008 disconnect failed
W/mali_winsys(14019): native_window_api_disconnect failed: -19
W/libEGL  (14019): EGLNativeWindowType 0xd395f008 disconnect failed
I/zygote  (14019): Do partial code cache collection, code=125KB, data=112KB
I/zygote  (14019): After code cache collection, code=125KB, data=112KB
I/zygote  (14019): Increasing code cache capacity to 512KB
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x960]-format:1
D/mali_winsys(14019): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x888]-format:1
I/Choreographer(14019): Skipped 34 frames!  The application may be doing too much work on its main thread.

darshankawar avatar Sep 03 '20 11:09 darshankawar

Thanks. I did not use the original example project, but included the code of it in my project. Now I tried the original example project with my firebase project and I also do not have the problem anymore. Could it be because of Java in firebase_auth example and Kotlin in my project? Or do you have any other advice where I have to search?

flutterfrank avatar Sep 03 '20 12:09 flutterfrank

I copied the contents of my old project into a new one and the problem is gone. I don't know what caused the problem but it bothered me after I updated firebase_auth.

flutterfrank avatar Sep 03 '20 17:09 flutterfrank

@flutterfrank I hit the exact same problem as you.

The reason why the problem occurs for me was because of the original project doesn't have this line in AndroidManifest.xml:

<meta-data
android:name="flutterEmbedding"
android:value="2" />

Then in MainActivity.kt, I've also used old version of flutterEmbedding to call GeneratedPluginRegistrant.registerWith(this)

And I've updated all other Android SDK, FlutterFire to latest versions. So maybe the app contains different versions of library and causing this to happen. That explains why moving code into a new flutter project fixed it as the flutterEmbedding is set to v2 in new project.

SG2010 avatar Oct 02 '20 19:10 SG2010