Reputation: 329
I am working on a SwiftUI app that has a lot of animation components to it. When the app is in foreground, the Custom Animation on Shapes work fine, no latency. They run smoothly at 60 FPS.
When the app comes to foreground after going from background, the app freezes for a few seconds and becomes completely non-responsive. Then it comes back to normal behavior.
I tried running the Time profiler instrument but the main thread is not blocked. Seems like there is no work happening on the CPU. What is interesting is that there is a gap between the background state and the foreground state (In the app lifecycle track) of the app as shown in the image.
What might be causing the app to freeze? Any ideas on how to debug this issue?
If it helps, the app also has a core-motion component to it which I am not pausing when the app goes to background.
Upvotes: 2
Views: 1610
Reputation: 186
I considered a similar issue. In my case it turned out that the modifier .drawingGroup() caused the issue. If I start my app everything was fine, but if I put it to background and bring it to foreground again it stopped for 4 seconds. I removed the drawingGroup modifier and this issue was solved.
Upvotes: 1