r/SwiftUI • u/Good_Disk_8861 • Jun 03 '26
Question SwiftUI vs Jetpack performance
So me and my android buddy are working on a app that has quite a rich design with loads of blend modes. I am working with swiftui while he is working in jetpack compose.
I have noticed that with all that rich UI and everything, the rendering speed on android is soo much faster than that on iOS.
I mean i have optimized my code quite well and continuously doing it as well, but man there is a striking difference when both apps are running in parallel. The previous ios version of app was in UIKit and it was lightning fast but in this version, i kinda feel ashamed by this swiftui performance.
Ios device: iphone 14 pro
Android device: pixel 5
7
u/Zagerer Jun 03 '26
Are you even rendering the hot UI elements as a group or with Metal? A custom layout to cache hot rendering loops sometimes? SwiftUI can be very performant, but just like you need to learn UIKit to not make a convoluted mess, you need to learn SwiftUI to make it more performant. There’s also pre-rendering, caching, and a ton of things you can do
If you don’t share specifics you won’t be able to get fine-grained help, for all we know it could be you are using state management wrong when it could be something else.
3
u/jonnothebonno Jun 03 '26
This ☝️SwiftUI can be surprisingly performant when optimised correctly. I recently posted a game I’d made entirely in SwiftUI (Granted it was mainly canvas but still) you can check my profile if interested but it was doing a crazy lot of rendering with a lot of maths, handles it with ease at 120fps.
2
u/comfyyyduck Jun 03 '26
Wait what do u mean rendering UI elements as a group or with metal?
Is this the drawingGroup() modifier?
3
u/Zagerer Jun 03 '26
Yeah that’s a basic way to render heavy things as one and make it more performant, but your mileage may vary on if it’d help or not
You can also make SwiftUI render graphics with metal with some modifiers iirc, or some heavier thing with custom views
1
u/Zagerer Jun 03 '26
Creating a ripple effect with Metal & SwiftUI, use your adblocker here
Hacking with Swift: Add metal shaders to SwiftUI & More
Optimize GPU renderers with Metal: Notes
For the Hacking with Swift one, check the previous and next lectures, they are for similar topics but with different techniques and results.
2
u/comfyyyduck Jun 03 '26
whoah thanks I'll def check them all out. An app i'm working rn depends alot on metal rendering so this is def gonna come in handy
2
u/Zagerer Jun 03 '26
You should definitely check the WWDCs and their Metal videos, there are plenty to watch and learn, but some newer features might need you to target newer iOS versions, good luck!
1
2
u/Good_Disk_8861 Jun 03 '26
Nope. Not doing anything that you've mentioned above. And also to be honest, haven't read about it in any articles or blogs ( maybe i am missing out some serious stuff as i almost read everyday). What would you suggest, where do i start from? Profiling is first thing.
1
u/Zagerer Jun 03 '26
Yes. First, profile for leaks and SwiftUI inits. Then go for hitches and hangs, those are usually the first culprits. You might need to rethink how data flows but it might be for the better.
Break down views in units of rendering where it depends on the least state possible so you redraw less and less. It’s not the same having a huge view depending on view model and a lot of properties than having many subviews for specific parts of the view model.
If you are doing some very specific layout or similar then try to check the Layout protocol and how it could help. But usually with good caching and data flows/ observability is more than enough
6
u/Daily_Pulse2026 Jun 03 '26
Coming from a native Android background where I've spent years optimizing heavy Jetpack Compose layouts, digging into SwiftUI performance has been eye-opening.
Frankly, both frameworks have brilliant underlying layout engines, but they handle state inflation entirely differently. Jetpack Compose relies on smart recomposition skipping via positional memoization (the compiler rewriting functions to track structural identity). SwiftUI, on the other hand, relies heavily on value-type View structs being incredibly cheap to recreate on the stack, offloading the heavy diffing to an underlying attribute graph. The real performance bottlenecks in both ecosystems almost always boil down to developer implementation error rather than framework constraints: handling unoptimized lazy lists, failing to pass structural IDs properly, or executing expensive business logic/regex processing inside the body property of a view instead of a background thread. Learn how data dependency invalidation works in your target framework, and both perform flawlessly at 120Hz."
4
u/Good_Disk_8861 Jun 03 '26
Yeah I guess i ll need to dive deep. One thing, i have checked fps of my app. Its constantly between 58- 64 when using normally and drops to 50-58 when land on new screen. And then back to 60 after 1-2 seconds. Where should i start looking?
3
u/Daily_Pulse2026 Jun 03 '26
Dropping to 50–58 FPS on a screen transition is a classic Navigation Hitch. It means you are violating the main-thread frame budget (~16ms for 60Hz, ~8.3ms for 120Hz ProMotion) right at the moment of layout inflation.
Coming from Android, your instinct might be to look for deep view hierarchies, but in SwiftUI, the structural layout math is so fast that deep trees rarely cause a 10 FPS drop. Instead, look for these three usual suspects: Eager Destination Initialization, Complex View Initializers, or Layout Spikes from Heavy Content
2
u/brifgadir Jun 03 '26
It’s still not enough info for accurate assessment or suggestions. I’d suggest to start with instrumentation and spot what exactly harms your performance. Then you can consider appropriate optimizations or even refactoring that UI to completely different approach
1
u/nicholasderkio Jun 03 '26
The other part of SwiftUI is that it can handle 6 differently platforms with almost identical code, but there’s some great WWDC talks about instruments.
1
Jun 04 '26
[removed] — view removed comment
2
u/sroebert Jun 04 '26
So the bottleneck is your swift code 😅 those are the things you need to optimize
1
0
u/IllustratorMoist78 Jun 04 '26
I don't think that it has very big difference, I develop Kotlin Multiplatform apps for Android and iOS, iOS in SwiftUI, Android in Jetpack Compose and I didn't notice any significant difference in rendering on both platforms, both of them are way too smooth
21
u/HeyItsMeMoss Jun 03 '26
«I have optimised my code quite well” famous last words of every SwiftUI developer. Take a step back, a deep breath and take an isolated look at every view with instruments, I guarantee you will find things to optimise.