Status Update
Comments
ae...@google.com <ae...@google.com> #2
tp...@gmail.com <tp...@gmail.com> #3
Box(modifier = imageModifier.background(Color.Gray))
I am curious if the scrolling will still be laggy in such case
tp...@gmail.com <tp...@gmail.com> #4
I have also tried the codelab for the state tutorial (the add tasks codelab) and it only shows an icon and a Text as a row and is also choppy if we scroll
thanks for the feedback
tp...@gmail.com <tp...@gmail.com> #5
Branch: androidx-master-dev
commit 17cd20811cfd5df0dceb95706d76248f2f7f2e42
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Tue Sep 22 20:09:35 2020
Scroll performance optimization for LazyColumnFor/LazyRowFor
We were unnecessary recomposing all the visible items on every scroll offset if the items type was not stable(if it was stable the recomposition was skipped using the regular runtime logic). In this change I introduced the itemContent lambda caching logic which allows to reuse the same lambda instance for not changed items. If we pass the same lambda instance into subcomposition the runtime will skip the whole composition as there is nothing to recompose. We clear this cache if the new itemContentFactory was provided or if the parent constraints have been changed.
Bug: 168293643
Bug: 167972292
Bug: 165028371
Relnote: Performance optimizations for LazyColumnFor/LazyRowFor scrolling by not doing unnecessary recompositions during every scroll
Test: tested manually and with a new test for both LazyColumnFor and LazyRowFor. Instead of 18 recompositions for each item for a simple scroll we do none of them.
Change-Id: I64f6568fd1193a6d28e3e2e2205b977f4a5f116b
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnForTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowForTest.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/CachingItemContentFactory.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyFor.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyForState.kt
ma...@gmail.com <ma...@gmail.com> #6
Branch: androidx-master-dev
commit dc602125a9e5fc15a37ba4fa7610998a94ead29f
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Fri Sep 25 21:14:09 2020
Do less work in SubcomposeLayout when subcompose called with the same lambda
If the lambda object for the slot didn't change and there were no pending recompositons we can skip the whole subcompositions invocation as it will result in unchanged tree. Starting subcomposition is a heavy weight operation so this change allows to improve the measure benchmarks for LazyColumn scrolling by 88 percents.
To achieve it I added a hasPendingChanges() method for Composition class.
Bug: 168293643
Bug: 167972292
Bug: 165028371
Relnote: The scrolling performance of LazyColumn/Row is improved by doing less work in subcomposition on every scroll. The new hasInvalidations() method was added for Composition class. hasPendingChanges() method from Recomposer was renamed to hasInvalidations()
Test: This is not changing the behavior so I can't cover it with a unit test, but it dramatically improves the benchmark. So if this optimization will stop working in the future we will get a regression.
Change-Id: Ib2f324dd6845fd83321e0d4f3fa6e502c346dbc3
M compose/runtime/runtime/api/current.txt
M compose/runtime/runtime/api/public_plus_experimental_current.txt
M compose/runtime/runtime/api/restricted_current.txt
M compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/AmbientTests.kt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composition.kt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
M compose/test-utils/src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/ComposeView.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
M ui/ui-test/src/androidMain/kotlin/androidx/ui/test/android/ComposeIdlingResource.kt
M ui/ui-test/src/androidMain/kotlin/androidx/ui/test/android/CompositionAwaiter.kt
M ui/ui-test/src/desktopMain/kotlin/androidx/ui/test/DesktopComposeTestRule.kt
th...@gmail.com <th...@gmail.com> #7
I will close the bug as fixed for now, Please feel free to comment again if after migrating to alpha05 and starting using loadImageResource for an item the scrolling performance is still unacceptable. Thanks!
st...@google.com <st...@google.com> #8
Thanks for your efforts improving the performance of the lazy lists! I was able to observe some improvements.
However it's still slow from my testing on alpha05. I tried removing the image loading (which I was loading with Glide) and just replaced them with Box(Modifier.background(DsToken.colors.backgroundSecondary)
and the )(slow) performance is around the same for the initial scroll.
It seems, when all items have been rendered, it starts to scroll smoothly. So I supposed there's something slow with the initial composition for each of the lazy item. Before, the scrolling was just slow throughout the whole app session.
th...@gmail.com <th...@gmail.com> #9
maybe if you can create a working repro sample app which I can check out and debug more?
st...@google.com <st...@google.com> #10
Thomas, is your code also using AnimatedVectorDrawables like the example in the original report?
We are using AVDs in a dialog sample, but I haven't seen that error - perhaps you could test it on your devices to see if it can trigger the exception?
th...@gmail.com <th...@gmail.com> #11
AnimatedVectorDrawables
work fine on the Galaxy Watch4. I am actually using the sample for the open on phone animation you linked in my project already, which works without any issues.
nj...@google.com <nj...@google.com> #12
I have tried the sample github project in
I recommend updating to the latest version of compose or providing a more minimal sample application for the team to look into.
tp...@gmail.com <tp...@gmail.com> #13
Are you running the sample on specific device? The github project is crashing only on Huawei devices running Android 10 or certain android 7 devices. I have tried it again on emulator running on Android 7 API 24 also able to reproduce the crash. Video as attached.
2022-01-13 14:09:57.183 3991-3991/com.terence.composeTest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.terence.composeTest, PID: 3991
java.lang.NullPointerException
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:245)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:760)
at android.view.View.draw(View.java:17074)
at android.view.View.updateDisplayListIfDirty(View.java:16053)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:656)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:662)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:770)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2796)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2604)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2211)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:619)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
2022
ap...@google.com <ap...@google.com> #14
Branch: androidx-main
commit f4ad578674a55af824e19d6e921dcd68f5eeff82
Author: Nader Jawad <njawad@google.com>
Date: Wed Jan 12 16:10:47 2022
Add defensive null check
Add conditional let block within
logic to record drawing operations
in case the displaylist for a RenderNodeLayer
is attempted to be updated after the layer
has been destroyed
Fixes: 206677462
Test: re-ran compose tests
Change-Id: I838d3170547716fa35d6e9b630db995075e814d9
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/RenderNodeLayer.android.kt
to...@branchapp.com <to...@branchapp.com> #15
ri...@ffw.com <ri...@ffw.com> #16
th...@gmail.com <th...@gmail.com> #17
Thanks for the fix! I can confirm it works with the latest snapshot in my Wear OS app.
lc...@gmail.com <lc...@gmail.com> #18
Can this fix be ported to 1.1.0 version too? i see that its currently onl in 1.2.0-alpha02
fr...@instacart.com <fr...@instacart.com> #19
+1, this is forcing us to downgrade compose and kotlin, this needs to be in 1.1
be...@google.com <be...@google.com> #20
This fix has been cherry picked to 1.1.1 as well
na...@google.com <na...@google.com> #21
The following release(s) address this bug:
androidx.compose.ui:ui:1.3.0
Description
Hello, noticed a NPE crash in compose ui after updating from 1.1.0-alpha05 to 1.1.0-beta01. Crash happening in RenderNodeLayer.updateDisplayList and happening 100% on Android 10 Huawei devices as reported on crashlytics. Initially thought it was due to code obfuscation issue but managed to replicate it consistently on a non obfuscated build.
Noticed from the stacktrace that somehow drawBlock in updateDisplayList is null but not sure in what scenarios it could become null?