Skip to content

[Optimize] Enable SwiftUI's LogForEachSlowPath by default in debug builds#2350

Merged
Dimillian merged 1 commit intoDimillian:mainfrom
Kyle-Ye:performance/kyle/foreach
Oct 21, 2025
Merged

[Optimize] Enable SwiftUI's LogForEachSlowPath by default in debug builds#2350
Dimillian merged 1 commit intoDimillian:mainfrom
Kyle-Ye:performance/kyle/foreach

Conversation

@Kyle-Ye
Copy link
Contributor

@Kyle-Ye Kyle-Ye commented Oct 19, 2025

Always enable SwiftUI's LogForEachSlowPath in debug builds.

Summary

SwiftUI's ForEach documentation states that we can enable such log by adding -LogForEachSlowPath YES in launch arguments.

It is equivalent to set UserDefaults since the SwiftUI Runtime is always using UserDefaults to check it.

This PR makes this feature default to true in debug builds.

To disable such log, append -LogForEachSlowPath NO in launch arguments or simply comment out the added code.

Result

image

When hitting a slow path for ForEach, a warning log will be emitted and then we may consider taking some actions to fix it to improve render performance.

Unable to determine number of views per element in the collection Array<Action>. If this view only produces one view per element in the collection, consider views in a VStack to take the fast path.

Currently, I have found one for the Array<Action> data. A potential fix PR may be submitted later.

@Kyle-Ye Kyle-Ye changed the title [Optimize] Enable SwiftUI's LogForEachSlowPath by default in debug buidls [Optimize] Enable SwiftUI's LogForEachSlowPath by default in debug builds Oct 19, 2025
@Dimillian Dimillian merged commit 3332cef into Dimillian:main Oct 21, 2025
5 checks passed
jesusjimsa pushed a commit to jesusjimsa/IceCubesApp that referenced this pull request Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants