Is Compose prone to problems similar to which a de...
# compose
s
Is Compose prone to problems similar to which a deeply nested Android ViewGroup suffers? I mean double layout taxation, slow measure/layout phases, etc. On Android, we always tried to build a flat view hierarchy, without deep nesting or weights. And what with Compose?
z
Compose’s layout system forbids double layout passes, so it’s specifically designed to avoid that particular problem.
A slow layout is going to be slow no matter what, so if you have a really complex ConstraintLayout, it will be slower than a simple
Row
. That said, there’s been lots of talk about shoving some Composition work onto background threads, which might mitigate that problem (it’s not been super clear exactly what that will look like yet).
s
Wow, great news. Thanks.
Does Compose could inline or merge some view constructions to a single layout? For instance, a text and an icon?
Or I think it doesn't make any sense because Compose already is drawing on Canvas.
z
There are semantics operators to let you group the sets of layouts that accessibility tools like TalkBack see, but I don’t think that’s what you’re asking. Compose won’t merge layouts, but it shouldn’t need to. If nothing in a Composable changed, and it doesn’t need to be re-measured, then it shouldn’t be re-composed (or re-measured, or re-layed-out, or re-drawn, etc).
👍 1
s
lovely
r
@Sergey Y. The existing View system draws on Canvas too
That’s not relevant to merging
s
Well I mean the measuring
r
Anyway on your original question:
👍 1
Yes Compose will prevent layouts that work in multiple passes
but
Deep nesting means deeper call stacks, more code to execute, more state to track, potentially more complex drawing trees, more allocations, etc.
No matter what, doing less is always going to beat doing more 🙂
So: profile your app
If it’s too slow, optimize it, otherwise you’re good 🙂
l
lol. finally, i have the answer to all of my performance woes 🙂
🤣 4
s
So: profile your app
and keep calm. Yes, I know Colt's tagline 🙂 #perfmatters
r
@Leland Richardson [G] Performance work is pretty easy turns out, just make slow things fast!
l
As @Chuck Jazdzewski [G] once told me, all performance improvements end up boiling down to one of: 1. do less work 2. do work less often 3. use information you weren’t using before
👏 2
🙌 1
OK, I think we’ve sufficiently derailed this thread now…
❤️ 1
c
The actual quote is, 1. do less 2. do it less often 3. do it some other time
❤️ 1
🙌 1
The "use information you weren't using before" helps with the above.
l
ah, i knew i was gonna mess it up
this is why we have you do the perf work
c
You can still do 2/3 of the perf work...
🤣 7
r
Taking notes…
c
Why is this gem of a discussion hidden inside a slack thread? Why? I demand it be spun out into a Twitter thread or something. Especially those quotes 😛