codelab-android-paging
codelab-android-paging copied to clipboard
IllegalArgumentException: Additional prepend event after prepend state is done
with version "3.0.0-alpha08"
How to reproduce afaik:
with a PagingSource which can provide more elements than PagerConfig.maxSize,
- scroll down more items than maxSize,
- scroll up until a load needs to happen:
java.lang.IllegalArgumentException: Additional prepend event after prepend state is done at androidx.paging.SeparatorState.onInsert(Separators.kt:221) at androidx.paging.SeparatorState.onEvent(Separators.kt:173) at androidx.paging.SeparatorsKt$insertEventSeparators$$inlined$map$1$2.emit(Collect.kt:135) at androidx.paging.PagingDataKt$map$$inlined$transform$1$2.emit(Collect.kt:136) at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:58) at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Unknown Source:11) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:69) at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:185) at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:108) at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:308) at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:395) at kotlinx.coroutines.channels.AbstractChannel$ReceiveElement.completeResumeReceive(AbstractChannel.kt:872) at kotlinx.coroutines.channels.ArrayChannel.offerInternal(ArrayChannel.kt:83) at kotlinx.coroutines.channels.AbstractSendChannel.send(AbstractChannel.kt:133) at androidx.paging.PageFetcherSnapshot.doLoad(PageFetcherSnapshot.kt:487) at androidx.paging.PageFetcherSnapshot$doLoad$1.invokeSuspend(Unknown Source:12) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) 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:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Is it possible to provide a CoroutineContext that catches these exceptions so the app does not crash but we can report them?
Workaround: setting PagerConfig.maxSize = Int.MAX_VALUE but it defeats the purpose of using the paging library for infinite lists.
I had the same error but after updating Paging 3 to 3.0.0-alpha09 it is working. Version 3.0.0-alpha09
Fix for
IllegalArgumentExceptionbeing throw when using separators withRemoteMediatorand an invalidate is triggered while a remote load that would returnendOfPaginationis still running (I3a260)
I still see this error in 3.0.0-alpha10 when I set a maxSize 🤔
I'm still seeing this error in 3.0.1. In some parts of my app it's working flawlessly (same mediator & separators) and in other parts I'm getting the error highlighted by the OP.
Paging 3 Flashes in compose when prepand in JetPack Compose in alpha14
Update enablePlaceholder = false, stops auto prepend loads. This also introduces another bug as sroll prostion is at 0 of next list.