"IllegalArgumentException: Layer is redrawn" 使用带有 JetpackCompose 分页的 collectAsLazyListItems() 时滚动太快
"IllegalArgumentException: Layer is redrawn" while scrolling too fast using collectAsLazyListItems() with JetpackCompose paging
我在可组合项中使用 Flow<PagingData<T>>.collectAsLazyPagingItems()
扩展方法。
该流源自 RemoteMediator,我正在使用本地和远程数据源。
只有快速滚动时才会崩溃,慢速滚动时不会崩溃。
撰写版本:
compose_version = '1.0.0-alpha07'
nav_compose_version ='1.0.0-alpha02'
paging_compose_version = '1.0.0-alpha02'
崩溃是:
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@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.invoke(RenderNodeApi29.kt:159)
at androidx.compose.ui.platform.RenderNodeApi29$record.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)
正在升级以下版本:
撰写版本:
compose_version = '1.0.0-alpha08'
nav_compose_version ='1.0.0-alpha03'
paging_compose_version = '1.0.0-alpha03'
和 kotlin 版本 1.4.21(在 stdlib 和 kotlinCompilerVersion 中的 composeOptions 中)
消除了崩溃
我在可组合项中使用 Flow<PagingData<T>>.collectAsLazyPagingItems()
扩展方法。
该流源自 RemoteMediator,我正在使用本地和远程数据源。
只有快速滚动时才会崩溃,慢速滚动时不会崩溃。
撰写版本:
compose_version = '1.0.0-alpha07'
nav_compose_version ='1.0.0-alpha02'
paging_compose_version = '1.0.0-alpha02'
崩溃是:
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@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.invoke(RenderNodeApi29.kt:159)
at androidx.compose.ui.platform.RenderNodeApi29$record.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)
正在升级以下版本:
撰写版本: compose_version = '1.0.0-alpha08' nav_compose_version ='1.0.0-alpha03' paging_compose_version = '1.0.0-alpha03'
和 kotlin 版本 1.4.21(在 stdlib 和 kotlinCompilerVersion 中的 composeOptions 中)
消除了崩溃