codelab-android-paging icon indicating copy to clipboard operation
codelab-android-paging copied to clipboard

IllegalArgumentException: Additional prepend event after prepend state is done

Open alaeri opened this issue 4 years ago • 4 comments

with version "3.0.0-alpha08"

How to reproduce afaik:

with a PagingSource which can provide more elements than PagerConfig.maxSize,

  1. scroll down more items than maxSize,
  2. 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.

alaeri avatar Nov 02 '20 15:11 alaeri

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 IllegalArgumentException being throw when using separators with RemoteMediator and an invalidate is triggered while a remote load that would return endOfPagination is still running (I3a260)

CzarqR avatar Nov 16 '20 19:11 CzarqR

I still see this error in 3.0.0-alpha10 when I set a maxSize 🤔

emmaguy avatar Dec 04 '20 13:12 emmaguy

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.

AT-Studio avatar Sep 07 '21 00:09 AT-Studio

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.

prime-zs1 avatar Dec 17 '21 15:12 prime-zs1