firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.63k stars 1.83k forks source link

FirestorePagingAdapter simply crashes due to an unknown reason #2060

Open yuyuan20 opened 2 years ago

yuyuan20 commented 2 years ago

Step 2: Describe your environment

Step 3: Describe the problem:

Basically I am using the FirestorePagingAdapter for a simple chat app. What I noticed is that, when the PagingConfig pageSize is set to a lower number than the total items that can be retrieved from the firestore (for example 1), or when new data are added repeatedly to firestore and by calling refresh() after to update the recyclerview, the app just simply crashes. Here is the log:

Fatal Exception: io.reactivex.rxjava3.exceptions.UndeliverableException
The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.InterruptedException
io.reactivex.rxjava3.plugins.RxJavaPlugins.onError (RxJavaPlugins.java:372)
io.reactivex.rxjava3.internal.operators.single.SingleFromCallable.subscribeActual (SingleFromCallable.java:49)
io.reactivex.rxjava3.core.Single.subscribe (Single.java:4813)
io.reactivex.rxjava3.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run (SingleSubscribeOn.java:89)
io.reactivex.rxjava3.core.Scheduler$DisposeTask.run (Scheduler.java:644)
io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:65)
io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:56)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:307)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
java.lang.Thread.run (Thread.java:1012)

Caused by java.lang.InterruptedException
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1040)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly (AbstractQueuedSynchronizer.java:1345)
java.util.concurrent.CountDownLatch.await (CountDownLatch.java:232)
com.google.android.gms.tasks.zzad.zza (com.google.android.gms:play-services-tasks@@18.0.1:1)
com.google.android.gms.tasks.Tasks.await (com.google.android.gms:play-services-tasks@@18.0.1:7)
com.firebase.ui.firestore.paging.FirestorePagingSource.lambda$loadSingle$0$com-firebase-ui-firestore-paging-FirestorePagingSource (FirestorePagingSource.java:42)
com.firebase.ui.firestore.paging.FirestorePagingSource$$ExternalSyntheticLambda1.call (Unknown Source:4)
io.reactivex.rxjava3.internal.operators.single.SingleFromCallable.subscribeActual (SingleFromCallable.java:43)
io.reactivex.rxjava3.core.Single.subscribe (Single.java:4813)
io.reactivex.rxjava3.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run (SingleSubscribeOn.java:89)
io.reactivex.rxjava3.core.Scheduler$DisposeTask.run (Scheduler.java:644)
io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:65)
io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:56)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:307)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
java.lang.Thread.run (Thread.java:1012)

This is the code for setting up the adapter:

Query baseQuery = reference.orderBy(CHAT_TIMESTAMP, Query.Direction.ASCENDING);
        PagingConfig pagingConfig = new PagingConfig(20);
        FirestorePagingOptions<Chat> options = new FirestorePagingOptions.Builder<Chat>()
                .setLifecycleOwner(this)
                .setQuery(baseQuery,pagingConfig,Chat.class)
                .build();
        mAdapter = new ChatMessageAdapter(options);

The initial load is executed without any crash but adding more items repeatedly or lowering the pageSize results in an unexpected crash. What is causing this issue? I am using androidx.paging version 3.1.1 by the way. Regards.