https://kotlinlang.org logo
#compose
Title
# compose
j

Jacob Ras

08/25/2023, 11:01 PM
Has anyone tried measuring the size increase on a Compose multiplatform app? I built a one-screen sample app that loads a list of cat pictures and shows them in a list. Clicking one enlarges it. I built it native (SwiftUI on iOS), KMP (Compose) and in Flutter to compare the three. On Android I'm seeing expected results (available in repo below). On iOS however, the size increase seems excessive. A thinned release build: native 1.7 MB, Compose: 24.8 MB, Flutter 48.1 MB. Debug build for simulator shows a similar ratio (4.6 / 57.6 / 91.8 MB). I don't think the Compose build is supposed to be that big, since I'm just using a couple of components. Please correct me if I'm wrong! 🙏 I have one guess: that the library isn't being stripped. I tried opening up the iOS archive without any luck (only binary files, didn't understand much of it 😬) All code + Android comparison results: https://github.com/jacobras/flutter-vs-native-vs-kmp Feel free to play around with it.
😮 2
👍 6
p

Pablichjenkov

08/25/2023, 11:25 PM
25MB is not a big number these days tbh. Thanks for the research btw
🙂 3
j

Jacob Ras

08/25/2023, 11:59 PM
Sure, it's just that the Android app also contains the Compose framework in the APK and it's only 1.5 MB. Quite a difference!
p

Pablichjenkov

08/26/2023, 12:27 AM
Ahh right, see your point. But well it could be do to other reasons. Android doesn't package the framework, is in the device already
1
Not sure about iOS
l

Landry Norris

08/26/2023, 12:51 AM
Compose on iOS needs to ship a copy of skia (same as Flutter). Android has its own shared skia binary that the Canvas API uses.
👍 1
👍🏾 1
c

Colton Idle

08/26/2023, 5:59 AM
thanks for the repo. thats super helpful. i do feel like most iOS apps these days are in the 100MB+, but seeing something built natively in 2MB and in compose be 25MB is a bit concerning. i wonder if theres any sort of treeshaking that could occur.
x

xoangon

08/26/2023, 7:11 AM
Really interesting comparison @Jacob Ras! I'd like to know what is actually shipped with the iOS app when built using CMP. @Pablichjenkov you're right. The Android Views are bundled with the Android OS, while Compose is shipped as unbundled. On the iOS side, both the UiKit and Swift UI are bundled with the OS. This Medium post does really good at comparing them both
s

shikasd

08/26/2023, 8:17 PM
Both Flutter and Compose have to ship Skia on iOS for rendering purposes, as iOS rendering engine is pretty different. On Android, Compose doesn't have to do this, as it relies on built-in Skia shipped with Android
Note that Flutter ships Skia on Android too, you'll get similarly sized APK there
c

Colton Idle

08/27/2023, 1:10 AM
So whats the smallest we can get skia for ios? in other words... whats the smallest compose multiplatform ios app someone could make?
s

shikasd

08/27/2023, 2:13 AM
Technically, you don't need Skia, if you wrap UIKit views with Compose But in general, Skia is pretty big, probably worth checking how Flutter addresses this problem
c

Colton Idle

08/27/2023, 3:21 PM
interesting.yeah i want skia because i want compose ui on ios. if i get some time at some point i might try to see what just adding skia to ios does in terms of app package size. thanks Andrei
j

Jacob Ras

09/21/2023, 11:45 AM
Thanks for all the help here! I took a closer look at the app thinning reports. The right iOS sizes are: native 1.7 MB, KMP 24.8 MB and Flutter 17.9 MB. My iOS colleague also got the benchmarks running on an iPhone 12 Mini, so the comparison is a lot more complete now 🙂 I've written a blog post about it: https://medium.com/@jacobras/android-ios-native-vs-flutter-vs-compose-multiplatform-7ef3d5ec2a56 but if you want to go straight to the data, check out the repository linked above.
👍 2
47 Views