I use Flow<PagingData<T>>.collectAsLazyPagingItems() extension method in my composable.
The flow originates from a RemoteMediator, I'm using local and remote data sources.
It crashes only when I scroll fast, it does not happen when scrolling slowly.

compose versions:
compose_version = '1.0.0-alpha07'
nav_compose_version ='1.0.0-alpha02'
paging_compose_version = '1.0.0-alpha02'

The crash is:

com.zk.trackshows E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.zk.trackshows, PID: 22201
    java.lang.IllegalArgumentException: Layer is redrawn for LayoutNode in state NeedsRelayout [LayoutNode@56ee45a children: 1 measureBlocks: androidx.compose.ui.layout.SubcomposeLayoutState$createMeasureBlocks$1@772aaf4]
        at androidx.compose.ui.node.LayerWrapper.invoke(LayerWrapper.kt:167)
        at androidx.compose.ui.node.LayerWrapper.invoke(Unknown Source:3)
        at androidx.compose.ui.platform.RenderNodeApi29$record$1$1.invoke(RenderNodeApi29.kt:159)
        at androidx.compose.ui.platform.RenderNodeApi29$record$1$1.invoke(Unknown Source:0)
        at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:1721)
        at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:128)
        at androidx.compose.ui.platform.AndroidComposeView.observeLayerModelReads(AndroidComposeView.kt:494)
        at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.kt:158)
        at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.kt:192)
        at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.kt:563)
        at android.view.View.draw(View.java:22175)
        at android.view.View.updateDisplayListIfDirty(View.java:21024)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4441)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4414)
        at android.view.View.updateDisplayListIfDirty(View.java:20984)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4441)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4414)
        at android.view.View.updateDisplayListIfDirty(View.java:20984)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4441)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4414)
        at android.view.View.updateDisplayListIfDirty(View.java:20984)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4441)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4414)
        at android.view.View.updateDisplayListIfDirty(View.java:20984)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4441)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4414)
        at android.view.View.updateDisplayListIfDirty(View.java:20984)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:582)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:588)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:665)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:4048)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3757)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3026)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1963)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8237)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
        at android.view.Choreographer.doCallbacks(Choreographer.java:1041)
        at android.view.Choreographer.doFrame(Choreographer.java:953)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1220)
        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:7711)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
1

There are 1 answers

0
Ziv Kesten On BEST ANSWER

Upgrading the following versions:

compose versions: compose_version = '1.0.0-alpha08' nav_compose_version ='1.0.0-alpha03' paging_compose_version = '1.0.0-alpha03'

And kotlin version 1.4.21 (in both stdlib and kotlinCompilerVersion in composeOptions)

Eliminated the crash