simibac / ConfettiSwiftUI

SwiftUI Package for Configurable Confetti Animation 🎉
MIT License
1.71k stars 117 forks source link

Flickering / Stuttering animation if compile app on Xcode: 16.0 #53

Open ukushu opened 1 month ago

ukushu commented 1 month ago

Expected Behaviour

no Flickering / Stuttering

Actual Behaviour

Flickering / Stuttering

Steps to Reproduce the Issue

Just apply ConfettiSwiftUI and run confetti.

iOS app or MacOS app - does not matter. Can be reproduced on both platforms.

iOS: On phisical device and on simulator both.

Xcode version: 16.0 (16A242d)

PS: Xcode 15.4 (15F31d) wasn't affected by the issue. But Xcode 15.4 cannot be installed on macOS: 15.0.0 / 15.0.1

leonboe1 commented 3 weeks ago

I also have the same issue and reported it in Feedback Assistant. Everyone having the same issue, please also file a bug report in Feedback Assistant and refer to my report FB15672116.

https://feedbackassistant.apple.com

PS: You can still use Xcode 15.4 on macOS 15.1 if you right-click Xcode, then click on show packet contents and finally manually run the embedded Xcode executable.

dleuck commented 3 weeks ago

We are also having problems with delays and flickering. I hope its fixed soon so we don't have to pull it out of our app.

TomBastable commented 2 weeks ago

Also experiencing the same issue, exact same steps as the OP to reproduce.

ukushu commented 2 weeks ago

UPD: this bug cannot be reproduced on release build in the AppStore. (I didn't tried local release build)

I think in this case this bug can be closed as there is no matter how it looks on debug build.

For repo author: but at least better to investigate the issue deeper

leonboe1 commented 1 week ago

This is the response from Apple:

Thank you for filing this feedback report. We reviewed your report and determined the behavior you experienced is currently functioning as intended.

In Xcode 16.0, unoptimized debug builds implicitly wrap usages of SwiftUI some View types (such as the return type from body) in AnyView. This is done to allow SwiftUI Previews to dynamically replace the implementation of methods like body without building separate copies of the entire project.

While functionally equivalent, using AnyView in some cases can lead to slower SwiftUI performance when a view returning some View from its body is used as a direct child of a lazy container. This can be worked around by wrapping those views in an HStack or VStack , for example:

List { ForEach(…) { HStack { MyRowView() } } }

Alternatively, there is a new build setting SWIFT_ENABLE_OPAQUE_TYPE_ERASURE that controls the implicit wrapping of views in AnyView. To get fast SwiftUI previews, the setting defaults to YES, but can be set to NO if you want to experiment with how this affects debug-time performance in specific targets in your project. This will disable all previews support for the target. This will have no effect on release builds, which is where performance should be accurately evaluated.

In this case, the stutter is not due to a lazy container, but just the overhead of AnyView given the large number of views being rendered at one time, so if you want optimal debug performance you'll need to use the build setting.