firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.73k stars 3.98k forks source link

Access to firestoreInstanceCache not always synchronized #16668

Closed tdickopp closed 1 week ago

tdickopp commented 1 week ago

Is there an existing issue for this?

Which plugins are affected?

Core

Which platforms are affected?

Android

Description

I got the below stacktrace from a customer (cf. b/375684078). It seems access to firestoreInstanceCache is not synchronized here (and maybe also not here).

Reproducing the issue

  1. Connect to two Firestore instances using the same project but different databases.
  2. Use the "Hot restart" in the (Android?) IDE.

Firebase Core version

2.27.0

Flutter Version

3.19.0

Relevant Log Output

22:52:03.707 E [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception:
PlatformException(java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException:
java.util.ConcurrentModificationException, ExecutionException, Cause:
java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException, Stacktrace:
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException:
java.util.ConcurrentModificationException (Ask Gemini)
at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-
tasks@@18.1.0:5)
at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-
tasks@@18.1.0:9)
at
io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin.lambda$initializeCore$3$io-flutter-
plugins-firebase-core-FlutterFirebaseCorePlugin(FlutterFirebaseCorePlugin.java:175)
at
io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin$$ExternalSyntheticLambda1.run(Unknown
Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.util.concurrent.ExecutionException:
java.util.ConcurrentModificationException
at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-
tasks@@18.1.0:5)
at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-
io.flutter.plugins.firebase.core.FlutterFirebasePluginRegistry.lambda$didReinitializeFirebaseCore$1(Fl
at
io.flutter.plugins.firebase.core.FlutterFirebasePluginRegistry$$ExternalSyntheticLambda0.run(Unknown
Source:2)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1603)
at java.util.HashMap$EntryIterator.next(HashMap.java:1636)
at java.util.HashMap$EntryIterator.next(HashMap.java:1634)
at
io.flutter.plugins.firebase.firestore.FlutterFirebaseFirestorePlugin.lambda$didReinitializeFirebaseCor
flutter-plugins-firebase-firestore-
FlutterFirebaseFirestorePlugin(FlutterFirebaseFirestorePlugin.java:204)
at
io.flutter.plugins.firebase.firestore.FlutterFirebaseFirestorePlugin$$ExternalSyntheticLambda13.run(Un
Source:4)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
, null)

Flutter dependencies

N/A

Additional context and comments

N/A