Skip to content

🐛 [firebase_auth] NullPointerException when ID token changed but channel is gone #4416

Closed
@ened

Description

@ened

Bug report

Crashlytics stack trace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object, io.flutter.plugin.common.MethodChannel$Result)' on a null object reference
       at io.flutter.plugins.firebase.auth.FlutterFirebaseAuthPlugin.lambda$null$1(FlutterFirebaseAuthPlugin.java:539)
       at io.flutter.plugins.firebase.auth.-$$Lambda$FlutterFirebaseAuthPlugin$SQAGnfsVv7byAY7rk65tey1yNTg.onIdTokenChanged(-.java:4)
       at com.google.firebase.auth.zzi.run(zzi.java:2)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at com.google.android.gms.internal.firebase_auth.zzj.dispatchMessage(zzj.java:6)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:8154)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Root cause: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java#L539

                  channel.invokeMethod(
                      "Auth#idTokenChanges",
                      event,
                      getMethodChannelResultHandler("Auth#idTokenChanges"));

Steps to reproduce

Not sure for a real App, but we should be writing having a driver test for it.

My suggestion is to move ID token listener & auth state listener into a EventStream (same approach like #4209) and get rid of the issue from the ground up. I'm happy to work on a PR for this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions