SwiftUI Laggy on a Real Device

I have recently started Beta Testing my SwiftUI App on my iPhone 6s, previously I was testing it on the iPhone 12 Simulator. While Testing on the Real Device I encountered issues like:
  1. CPU going past 98%

  2. Really Laggy ScrollView

  3. Tab Bar Freezes Randomly

Since My app is going to go in Production State in a few days, Since this is my first iOS App as well, I am not too sure if these issues are because of SwiftUI, my Phone or what, I have asked Apple Support but, haven't received a response so far.
My App Stats:
Lines of Code: ~1,500
CPU Usage on Simulator: Max. 10%
Bundle Size: 2MB
RAM Max. on Simulator: 32.3mb

Accepted Reply

Almost 8 months later, and here are my thoughts on the issue, 8 months ago, SwiftUI was pretty new and had a lot of hidden bugs, especially in testing.

The problem I think I had was that when testing in debug mode, the system would perform more calculations and since I was rendering a lot of images in LazyVStack, which is good for lazy-loading but throttles when you feed in too much stuff, after scrolling through 25 images, the LazyVStack started throttling which caused the app to freeze.

This is my own thinking, Apple never responded back, even though I used one of my incidents, and even sent all the copyrighted code. My solution to this problem was: Just migrate to UIKit, SwiftUI is too young for complex applications with a lot of images and network requests, it just can't handle all the pressure.

Hopefully this helps someone.

  • I'm developing for a 27 inch iMac and having the exact same problem as you. The problem is obvious: the entire UI operates on just one thread AND re-renders stuff that hasn't been updated. There's no way to know when the rendering has finished and there's no way to separate areas within the UI to render independently. SwiftUI is nothing more than a failed proof of concept and Apple never respond when they know its their fault.

    I've found it hard enough learning Swift and SwiftUI, so I don't want start learning an about to be depreciated UIKit. So come on dear Apple, give us something that JUST WORKS.

    Perhaps I should have chosen Python. Certainly the networking would have been easier!

Add a Comment

Replies

Almost 8 months later, and here are my thoughts on the issue, 8 months ago, SwiftUI was pretty new and had a lot of hidden bugs, especially in testing.

The problem I think I had was that when testing in debug mode, the system would perform more calculations and since I was rendering a lot of images in LazyVStack, which is good for lazy-loading but throttles when you feed in too much stuff, after scrolling through 25 images, the LazyVStack started throttling which caused the app to freeze.

This is my own thinking, Apple never responded back, even though I used one of my incidents, and even sent all the copyrighted code. My solution to this problem was: Just migrate to UIKit, SwiftUI is too young for complex applications with a lot of images and network requests, it just can't handle all the pressure.

Hopefully this helps someone.

  • I'm developing for a 27 inch iMac and having the exact same problem as you. The problem is obvious: the entire UI operates on just one thread AND re-renders stuff that hasn't been updated. There's no way to know when the rendering has finished and there's no way to separate areas within the UI to render independently. SwiftUI is nothing more than a failed proof of concept and Apple never respond when they know its their fault.

    I've found it hard enough learning Swift and SwiftUI, so I don't want start learning an about to be depreciated UIKit. So come on dear Apple, give us something that JUST WORKS.

    Perhaps I should have chosen Python. Certainly the networking would have been easier!

Add a Comment

Has it been fixed now?