https://kotlinlang.org logo
c

Ciprian Grigor

10/15/2020, 3:25 PM
I wonder how does compose UI toolkit works internally? Does it have something similar to Flutter RenderObject tree, heavy UI objects which are reused?
👍 1
z

Zach Klippenstein (he/him) [MOD]

10/15/2020, 3:29 PM
👍 1
c

Ciprian Grigor

10/15/2020, 3:36 PM
Hard to get an answer from there
j

jim

10/15/2020, 3:42 PM
If you want to understand how it works, you're going to need to dive into the code sooner or later. Zach is correct, we basically create trees of LayoutNodes, which are not widget instances (so unlike flutter) but are lightweight (like flutter) and are updated instead of recreated (which is why we have a compiler to help with tracking/applying those changes optimally).
z

Zach Klippenstein (he/him) [MOD]

10/15/2020, 3:43 PM
For drawing, it uses Android’s RenderNode for drawing layers, which is also lighter-weight (and lower-level) than android views. However, on older android versions that don’t have RenderNodes, it falls back to Views for layers. https://developer.android.com/reference/android/graphics/RenderNode
👆 1
👍 5
c

Ciprian Grigor

10/15/2020, 3:52 PM
Thanks for clear explanation: kind of similar RenderNode = RenderObject, however is closer to android and android views can be intermixed with compose because of that
b

Bsn Net

10/15/2020, 10:13 PM
what Android version is considered old?
z

Zach Klippenstein (he/him) [MOD]

10/15/2020, 10:15 PM
Whichever version is before the first one where RenderNode was introduced
4 Views