简体   繁体   English

带有 LazyRows 的 LazyColumn 的性能

[英]Performance of LazyColumn with LazyRows inside it

I have a lazy column with lazy rows inside it, like in the image:我有一个惰性列,里面有惰性行,如图所示:

在此处输入图像描述

I am testing on a 2017 middle-quality phone with Android 9. Release build with R8 enabled.我正在使用 Android 9 在 2017 年中等质量的手机上进行测试。启用 R8 的发布版本。

Scroll performance in rows are pretty good, but in column performance is very low.行中的滚动性能非常好,但列中的性能非常低。 I am using simplest composables, nothing special.我使用的是最简单的可组合项,没什么特别的。

LazyColumn { 
     items(
          items = rows,
          key = { it.id },
          contentType = { it.type}
     ) { 
          LazyRow {
               items(videos) {
                    Video()
               }
          }
     }
 } 

I had the same issue when playing with it months ago.几个月前玩它时我遇到了同样的问题。 I see some coworkers used ImmutableList for the items though and had better luck with that.我看到一些同事使用 ImmutableList 作为项目,并且运气更好。 Might be worth a try - the issue I had is that there was a ton of recomposition happening as well so make sure that is good with a profiler可能值得一试——我遇到的问题是也发生了大量的重组,所以要确保它对分析器是好的

I have the same problem.我也有同样的问题。 But it occurs randomly.但它是随机发生的。 I used a structure like yours and it appears very smooth at beginning.我使用了像你这样的结构,一开始看起来很顺利。 But after I add some new feature to the screan, it becomes laggy sometimes.但是在我向屏幕添加一些新功能后,它有时会变得迟钝。 When I keep scrolling up and down, I can see it forzen for s split second sometimes.当我继续上下滚动时,有时我会看到它停顿了一秒钟。 I've tried some sample apps from github with lazy features.我已经尝试了一些来自 github 的具有惰性功能的示例应用程序。 They have the same problems.他们有同样的问题。 One thing for sure is that the debug mode does make the lazycolumn and lazyrow slow.可以肯定的一件事是调试模式确实会使 lazycolumn 和 lazyrow 变慢。 Build an apk and see if it appears better.构建一个 apk,看看它是否看起来更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM