Could one say Compose ui is more equivalent to flu...
# compose
Could one say Compose ui is more equivalent to flutter ui, than os native?
👌 1
Yes. Both of them have declarative way of writing UI, unlike old View system that is imperative.
In terms of code style it may be true but in terms of internals, not really. Flutter does many things (e.g. all the rendering) itself while Jetpack Compose usually uses platform native mechanism.
My understanding was that Compose actually reimplements the native controls and draws to a canvas.
Compose is similar to flutter. It doesn't use native mechanics in terms of the view- flutter same thing. If you meant like React Native which reuses android view widgets
Compose and flutter both draw straight to canvas
Not really. Jetpack Compose doesn’t directly draw to canvas. It uses RenderNode API on API 23-27 and API 29+, and View API on API 21-22 and API 28. Rendering is all done by the platform, same as View system. See the source here for details.
Yea one big ComposeView but your actual ui elements are "just" canvas calls, no?
What happened with API 28 in particular? Seems really odd that older versions use RenderNode that the latest use too, but all of a sudden API 28 also uses what’s being used by the quite old API 21-22 versions?
Another obvious proof is that Jetpack Compose doesn’t bundle any rendering libraries, while flutter bundles Skia for rendering.
Before API 29
is system hidden API and on API 28 it is in the blocklist of non-sdk API usage.
So is my assumption wrong? Thats its one big View instance from OS point of view?
It’s true on API 23-27 and API 29+.
And flutter doesnt do the same thing? i.e. on big FlutterView where its draws by opengl or whatever they do
Jetpack Compose: Create a custom view, override its
and use standard Android
API to do some drawing, letting the platform handle all the rendering stuff. Flutter: Create a
, do custom drawing using its own API and rendering to the
using Skia. Am I clear?
yea btw isnt canvas implemented in skia?
The rendering part of Android is called HWUI. If you are interested you can do some searching using that keyword but tl;dr: not necessarily.
@Albert Chang has the right of it. If you're looking for a quick analogy, Compose UI is closer to being a RecyclerView2 than it is to Flutter in terms of how they interact with Android
And to be clear: the platform’s Canvas uses Skia internally
hwui is a layer on top that did all the drawing for many years but since P, Skia does the drawing again. hwui does a lot of other things though (managing render nodes, animations, frame pacing, etc.)
(And before Android 3.0, Canvas was pure, direct Skia)
So…Skia everywhere 😅
More or less yes. Skia came from Android so it makes sense we and other google teams use it
👍 2
Chrome uses Skia too