The latest version 8.0.1 crashes the app with IllegalStateException (whereas 8.0.0 works completely fine)
Environment
- Android device: Android Emulator
- Android OS version: Android 12
- Google Play Services version: -
- Firebase/Play Services SDK version: 28.4.2 (Firebase BOM)
- FirebaseUI version: 8.0.1
Problem:
Steps to reproduce:
Scrolling through FirestorePagingAdapter will crash the app after first or second fetch.
Observed Results:
App crashes with following error.
java.lang.IllegalStateException: The same value, PageKey{StartAfter=KEY_ID_HERE, EndBefore=null}, was passed as the nextKey in two
sequential Pages loaded from a PagingSource. Re-using load keys in
PagingSource is often an error, and must be explicitly enabled by
overriding PagingSource.keyReuseSupported.
at androidx.paging.PageFetcherSnapshot.doLoad(PageFetcherSnapshot.kt:419)
at androidx.paging.PageFetcherSnapshot.access$doLoad(PageFetcherSnapshot.kt:54)
at androidx.paging.PageFetcherSnapshot$doLoad$1.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Expected Results:
Load the next set of data
Relevant Code:
It works perfectly fine with FirebaseUI version 8.0.0, but upgrading to 8.0.1 crashes the app with following error.
the same error occured
I posted this a month ago, but no answers yet
https://stackoverflow.com/questions/71961407/firestorepagingadapter-crashes-when-scrolling-in-version-8-0-1
Internal bug filed at b/235862945
Thanks for filing this @vedprakashwagh ! I'll have a look at it. ( looks like a duplicate of #2000 )
Edit: this is not a duplicate because it refers to Firestore, while the other issue refers to the Realtime Database.
@vedprakashwagh Can you please also share the full Query that you passed to your FirebaseRecyclerPagingAdapter?
@thatfiredev I'm getting the same error with this Query:
Query query = notebookRef.orderBy("timestampSort", Query.Direction.ASCENDING);
@thatfiredev Hey! Yes, here's the query.
query = Firebase.firestore.collection("collectionName") .orderBy("keyOfTimestamp", Query.Direction.DESCENDING)
After two days of debugging my code, I also figured that version 8.0.0 still works where 8.0.1 crashes on the first paging load (not initial). Query also is of the sort Firebase.firestore.collection("collectionName") .orderBy("keyOfTimestamp", Query.Direction.DESCENDING)
This issue should be solved in version 8.0.2