I have seen the following exception from a few clients now:
Fatal Exception: java.lang.IllegalStateException: Reply already submitted
at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply + 35(DartMessenger.java:35)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error + 14(MethodChannel.java:14)
at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$3.onComplete + 29(CloudFirestorePlugin.java:29)
at com.google.android.gms.tasks.zzj.run + 23(zzj.java:23)
at android.os.Handler.handleCallback + 883(Handler.java:883)
at android.os.Handler.dispatchMessage + 100(Handler.java:100)
at android.os.Looper.loop + 214(Looper.java:214)
at android.app.ActivityThread.main + 7356(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 492(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main + 930(ZygoteInit.java:930)
I was not quite sure what this was until I recently worked on resolving a similar crash.
Having said that, I am pretty sure the crash comes from here:
https://github.com/FirebaseExtended/flutterfire/blob/bfc666daa89698c9fdc342e7ae521ec5e4e8ec5b/packages/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java#L442
That is a big strange because "Reply already submitted" sounds like a result was already sent, but it looks like it is quite possible that the following line could be called before that and the onComplete listener would still be called:
https://github.com/FirebaseExtended/flutterfire/blob/bfc666daa89698c9fdc342e7ae521ec5e4e8ec5b/packages/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java#L430
I will just try to sketch a fix for this because crashes are very bad UX, however, I cannot test my implementation because I cannot reproduce this issue when debugging (I only see it in Crashlytics).
I have seen the following exception from a few clients now:
I was not quite sure what this was until I recently worked on resolving a similar crash.
Having said that, I am pretty sure the crash comes from here:
https://github.com/FirebaseExtended/flutterfire/blob/bfc666daa89698c9fdc342e7ae521ec5e4e8ec5b/packages/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java#L442
That is a big strange because "Reply already submitted" sounds like a result was already sent, but it looks like it is quite possible that the following line could be called before that and the
onCompletelistener would still be called:https://github.com/FirebaseExtended/flutterfire/blob/bfc666daa89698c9fdc342e7ae521ec5e4e8ec5b/packages/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java#L430
I will just try to sketch a fix for this because crashes are very bad UX, however, I cannot test my implementation because I cannot reproduce this issue when debugging (I only see it in Crashlytics).