Hey guys, is there a way to pause/skip a recomposi...
# compose-android
h
Hey guys, is there a way to pause/skip a recomposition? For example when scrolling through a big list and when you just scroll fast, the displayed items have their compositions restarted even when displayed for a short amount of time, I noticed that it impacts a lot of our performance even in release mode, because we have complicated item types and some things need to be calculated in order to be displayed
z
If they aren’t composed, then they can’t be measured. If the list can’t measure its items, how does it know how far it can scroll?
Components should do minimal work on the first frame for this reason. We are always trying to keep first-party things cheap on the first frame, but there’s probably more to be done.
h
Sorry for the explanation, this might be better: We have one large item that you can scroll across multiple frames, sometimes the current item is not even starting to re/compose This causes jank because the current one also needs a calculation I hope it's clearer now
z
What do you mean by “current” item?
h
Current = when it becomes Visible sorry
z
I’m more confused now than I was earlier 😅 the big item is multiple times the scroll viewport in size? And when it’s in the viewport during scrolling there’s jank?
h
We have an item that is to be scrolled onto the screen across multiple frames, preventing the other large items from causing the current to start or restart composition 🤔 idk if this makes more sense
z
I’m still not sure what you mean by current. There can be multiple items in the viewport at once during scroll. I think a diagram or screen recording would help
h
I thought about opening a feature request/bug with a video recording attached, but it seems this is already thought off and being worked on https://android-review.googlesource.com/c/platform/frameworks/support/+/3057165
a
I have also faced this issue(in release build with baseline profile on) in my case I am rendering the markdown. I think in Recycler view we don’t use to face this problem as RV does rendering on bg thread and does it for few items while in compose it only does for single item. Previous thread at https://kotlinlang.slack.com/archives/C04TPPEQKEJ/p1708410539063179 Regarding weird multiple rendering of next item https://kotlinlang.slack.com/archives/C04TPPEQKEJ/p1715341704351489
c
As you noticed, this area is under active development. Pausable composition doesn't quite do what you want, in that it doesn't allow the composition to be skipped or paused in the frame. Once an composition is needed, it must be complete (composed, layout and draw). What it does is allow is for precomposition/premeasure to better utilize the main thread between frames allowing an item to be precomposed over multiple frames instead of blocking the next frame. This, in combination with current work around customizing prefetch policy and nested prefetching (lazy column with lazy rows, for example) will allow us to do more work between frames as well as reduce the amount of work performed in the frame itself.
thank you color 1
a
I can see that https://android-review.googlesource.com/c/platform/frameworks/support/+/3211838 is merged now. Is this live-in compose and with what version? also for complex items which require pausable composition do we need to set some value?
c
Pausable composition is not implicit. It requires support from the libraries above the runtime as using it requires explicit creation of a pausable composition and explicit driving the composition to completion. We are working on enabling this in the lazy list composables.
a
Hi thanks for reply, can't we do background composition for prefetching items to avoid the junk?