https://kotlinlang.org logo
#compose-android
Title
# compose-android
m

Michael Paus

12/01/2023, 9:11 AM
Skiko has support for Android too. Is there any way to use that with Compose? It would be nice to have such an option if a consistent multiplatform rendering infrastructure is more important than the smallest possible apk size. Lets-Plot seems to be using it too but how does that work? I haven’t found any documentation about it.
s

Sergey Y.

12/01/2023, 12:43 PM
I believe JetBrain's Compose is simply missing certain Android implementations to utilize Skia. Additionally, using own Skia renderer would immediately disrupt the usage of AndroidView components.
It is a two-sided coin
z

Zach Klippenstein (he/him) [MOD]

12/01/2023, 3:59 PM
The Android OS itself already uses Skia, it just wraps it with slightly higher-level APIs, which is what Compose uses on Android.
s

Sergey Y.

12/01/2023, 4:08 PM
it's not that simple, unfortunately
z

Zach Klippenstein (he/him) [MOD]

12/01/2023, 4:10 PM
i didn’t say anything about simple 🙂
👍 1
r

romainguy

12/01/2023, 4:37 PM
Rendering should be fairly consistant since like Zach said, both use Skia
m

Michael Paus

12/01/2023, 4:37 PM
I know that it is using Skia but probably not the same version that is used elsewhere depending on the age of your phone, or am I wrong with that assumption? And how do you get an instance of the above mentioned Skiko API? On other platforms you can ask for the native canvas but on Android this is not the same as elsewhere. It is the Android native canvas (which is probably the Android wrapper around Skia).
r

romainguy

12/01/2023, 4:37 PM
You are right that an older phone might have an older version of Skia
And yes on Android you get back an
android.graphics.Canvas
, which technically is not the wrapper around Skia either but a “recording Canvas”
This is what enables full interop between Compose and Views
m

Michael Paus

12/01/2023, 4:38 PM
And with “consistent” I do not only mean the behaviour but the fact that you can get the same low-lewel Skiko API on all platforms. Android is currently the only exception to that rule as far as I know.
r

romainguy

12/01/2023, 4:39 PM
(and a bunch of optimizations)
I would say the other platforms are the exceptions 😄
Skia is native to Android, as in it’s the rendering engine we’ve used since Android 1.0 (and we Open Sourced Skia too). We made the decision to not ship our own copy of Skia for multiple reasons:
• Interop like I mentioned
• Binary size
• To benefit from various optimizations implemented in “hwui” the layer between
Canvas
and Skia on Android
18 Views