-1

I created a SwiftUI View (in a UIKit based project) whose objective is to display a short animation in the front of the user screen. I developed it 8 month ago using Xcode 15 for iOS 17 with no problems.

Normal animation

But since iOS 18, I can observe huge lags in my animation only in Release app. The problem is not present in the Debug app.

Laggy Animation

It may not be apparent in the GIF, but on an iPhone Pro with Pro Motion display, it's clearly distinguishable.

I don't understand why this problem occurs, the animation is quite simple, it's just an offset displacement.

I tried many thing like:

  • Showing the animation with a UINavigationController

  • Showing the animation with a UIWindow

  • Moving the view with .position

  • Removing the GeometryReader

  • All other animation

  • withAnimation and .animation

  • Task and DispatchQueue

  • etc.

I found that the laggy animation occurs when I set the Optimization Level for the Swift Compiler - Code Generation to Optimize for Speed [-O]. That's very strange because we had this option on Release for iOS 17 and we had no lags.

A repository with sample code containing the configuration can be found here: https://github.com/Thibma/sample-animation-swiftui

Today the only option I used is to develop this feature in UIKit but it's too bad to skip the SwiftUI opportunity. :/

If you have any ideas to resolve this, I take!

Thank you!

New contributor
Thibma is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

0

Browse other questions tagged or ask your own question.