Skip to content

firebase-firestore-SDK causing an application to crash. #5571

@sumittiware

Description

@sumittiware

We have been using cloud_firestore dependency in out Flutter app and noticed an crash in the crashytics dashboard. It has the following stack-trace.

Fatal Exception: java.lang.RuntimeException: Internal error in Cloud Firestore (24.4.3).
       at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:545)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8680)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Caused by java.lang.UnsupportedOperationException:
       at java.util.AbstractMap.put(AbstractMap.java:209)
       at java.util.AbstractMap.putAll(AbstractMap.java:281)
       at com.google.firebase.firestore.local.LocalDocumentsView.populateOverlays(LocalDocumentsView.java:361)
       at com.google.firebase.firestore.local.LocalDocumentsView.getNextDocuments(LocalDocumentsView.java:344)
       at com.google.firebase.firestore.local.IndexBackfiller.writeEntriesForCollectionGroup(IndexBackfiller.java:136)
       at com.google.firebase.firestore.local.IndexBackfiller.writeIndexEntries(IndexBackfiller.java:119)
       at com.google.firebase.firestore.local.IndexBackfiller.lambda$backfill$0(IndexBackfiller.java:105)
       at com.google.firebase.firestore.local.SQLitePersistence.runTransaction(SQLitePersistence.java:228)
       at com.google.firebase.firestore.local.IndexBackfiller.backfill(IndexBackfiller.java:105)
       at com.google.firebase.firestore.local.IndexBackfiller$Scheduler.lambda$scheduleBackfill$0(IndexBackfiller.java:92)
       at com.google.firebase.firestore.util.AsyncQueue$DelayedTask.handleDelayElapsed(AsyncQueue.java:145)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
       at java.util.concurrent.FutureTask.run(FutureTask.java:264)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
       at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:235)
       at java.lang.Thread.run(Thread.java:1012)

It has something to do with the implementation of firebase-android-SDK.

From the above stack-trace we can identify that the the code is failing because it is trying to call put method on the abstract map, in java this method is not implemented.

at java.util.AbstractMap.put(AbstractMap.java:209)

Now, as we navigated down the stack-trace we have found that, there is a condition in the firestore-android-SDK that there a condition where the overlays is initialised with the Abstract map and passed down the code.

 Map<DocumentKey, Overlay> overlays =
        count - docs.size() > 0
            ? documentOverlayCache.getOverlays(
                collectionGroup, offset.getLargestBatchId(), count - docs.size())
            : Collections.emptyMap();

in above code emptyMap() returns an EmptyMap() which does not have put method implemented which is calling put for AbstractMap and in-turn throwing the UnsupportedOperationException.

image

LocalDocumentsResult getNextDocuments(String collectionGroup, IndexOffset offset, int count) {

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions