Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception: java.util.ConcurrentModificationException #5091

Closed
muriloventuroso opened this issue Jun 21, 2023 · 7 comments
Closed

Fatal Exception: java.util.ConcurrentModificationException #5091

muriloventuroso opened this issue Jun 21, 2023 · 7 comments
Assignees

Comments

@muriloventuroso
Copy link

While running the Android app, the following error was reported in the crash log.

Exception java.util.ConcurrentModificationException:
  at java.util.ArrayList$Itr.next (ArrayList.java:860)
  at com.google.firebase.firestore.core.Query.matchesOrderBy (Query.java:401)
  at com.google.firebase.firestore.core.Query.matches (Query.java:425)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.lambda$getDocumentsMatchingQuery$3 (SQLiteRemoteDocumentCache.java:257)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.lambda$processRowInBackground$2 (SQLiteRemoteDocumentCache.java:242)
  at com.google.firebase.firestore.util.BackgroundQueue.lambda$execute$0 (BackgroundQueue.java:39)
  at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0 (ThrottledForwardingExecutor.java:54)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at java.lang.Thread.run (Thread.java:919)

Steps to reproduce

I still haven't been able to reproduce the error on my Android devices or the emulator. But I get this error report everyday from my app users.

Additional context

Occurs on Android 10 (SDK 29)
Firebase Android SDK 32.0.0

@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@muriloventuroso
Copy link
Author

Another trace:

Exception java.lang.RuntimeException:
  at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3 (AsyncQueue.java:545)
  at android.os.Handler.handleCallback (Handler.java:883)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:214)
  at android.app.ActivityThread.main (ActivityThread.java:7386)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:980)
Caused by java.lang.RuntimeException: java.util.ConcurrentModificationException
  at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1 (AsyncQueue.java:333)
  at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:462)
  at java.util.concurrent.FutureTask.run (FutureTask.java:266)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:301)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run (AsyncQueue.java:235)
  at java.lang.Thread.run (Thread.java:919)
Caused by java.util.ConcurrentModificationException:
  at java.util.ArrayList$Itr.next (ArrayList.java:860)
  at com.google.firebase.firestore.core.Query.matchesOrderBy (Query.java:401)
  at com.google.firebase.firestore.core.Query.matches (Query.java:425)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.lambda$getDocumentsMatchingQuery$3 (SQLiteRemoteDocumentCache.java:257)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.lambda$processRowInBackground$2 (SQLiteRemoteDocumentCache.java:242)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.processRowInBackground (SQLiteRemoteDocumentCache.java:238)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.lambda$getAll$1 (SQLiteRemoteDocumentCache.java:221)
  at com.google.firebase.firestore.local.SQLitePersistence$Query.forEach (SQLitePersistence.java:495)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.getAll (SQLiteRemoteDocumentCache.java:221)
  at com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.getDocumentsMatchingQuery (SQLiteRemoteDocumentCache.java:253)
  at com.google.firebase.firestore.local.LocalDocumentsView.getDocumentsMatchingCollectionQuery (LocalDocumentsView.java:369)
  at com.google.firebase.firestore.local.LocalDocumentsView.getDocumentsMatchingCollectionGroupQuery (LocalDocumentsView.java:300)
  at com.google.firebase.firestore.local.LocalDocumentsView.getDocumentsMatchingQuery (LocalDocumentsView.java:268)
  at com.google.firebase.firestore.local.QueryEngine.executeFullCollectionScan (QueryEngine.java:248)
  at com.google.firebase.firestore.local.QueryEngine.getDocumentsMatchingQuery (QueryEngine.java:90)
  at com.google.firebase.firestore.local.LocalStore.executeQuery (LocalStore.java:858)
  at com.google.firebase.firestore.core.FirestoreClient.lambda$getDocumentsFromLocalCache$11 (FirestoreClient.java:222)
  at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1 (AsyncQueue.java:330)

@MarkDuckworth MarkDuckworth self-assigned this Jun 21, 2023
@MarkDuckworth
Copy link
Contributor

@muriloventuroso, thanks for reporting this, I've been looking into this issue but don't have a solution yet. If you find a repro, please let me know.

This may be the same issue as firebase/flutterfire#10745

@muriloventuroso
Copy link
Author

Yes, I think it's the same problem. And this issue had no updates.

Any new information I have will be shared here.

@Asuveroz
Copy link

Asuveroz commented Jun 25, 2023

Some of my app users are experiencing the same problem.

Firebase BoM: 32.0.0
Affected versions: Android 10, 11, 12

Stack trace gathered from the Firebase Crashlytics:

java.util.ConcurrentModificationException: 
    java.util.ArrayList$Itr.next(ArrayList.java:860)
    com.google.firebase.firestore.core.Query.matchesOrderBy(Query.java:401)
    com.google.firebase.firestore.core.Query.matches(Query.java:425)
    com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.lambda$getDocumentsMatchingQuery$3(SQLiteRemoteDocumentCache.java:257)
    com.google.firebase.firestore.local.SQLiteRemoteDocumentCache.lambda$processRowInBackground$2(SQLiteRemoteDocumentCache.java:242)
    com.google.firebase.firestore.util.BackgroundQueue.lambda$execute$0(BackgroundQueue.java:39)
    com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(ThrottledForwardingExecutor.java:54)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    java.lang.Thread.run(Thread.java:920)

@MarkDuckworth
Copy link
Contributor

I haven't been able to reproduce this error, but in reviewing the code in this call stack we identified a possible case of thread interference, which could be the root cause of the ConcurrentModificationException. The fix is in #5099.

@MarkDuckworth
Copy link
Contributor

The fix will release in v24.6.2, which should be out soon. Please let me know if you continue to have issues after updating to v24.6.2.

@firebase firebase locked and limited conversation to collaborators Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants
@MarkDuckworth @muriloventuroso @google-oss-bot @Asuveroz @argzdev and others