Prevent reduce function from being optimized #3683
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Ever since Swift 6 (i.e. TCA 1.15.0) there exists an issue in the Swift compiler that can lead to crashes only when the app has been archived for release. Greater detail was documented in this discussion.
Unfortunately, we have still been unable to identify the conditions in which the crash occurs so it makes reproducing the issue prohibitively difficult in a sample app (making testing this PR difficult for someone not experiencing the crash).
However, we were able to pare down our production application considerably and share this with Apple developer support who were also able to reproduce the issue. They've acknowledged this to be an issue rooted in the Swift compiler.
Below is the latest response from the internal email thread we've had open with developer support:
Changes:
@_optimize(none)
toreduce(into:action:)
per Apple's guidance to mitigate crashes.Testing:
As mentioned, testing this can be rather difficult if you don't already have an app that exhibits the issue. We were able to clone the latest TCA release, add it as a local dependency, make the change, and verify that the crashes no longer occurred on archived release builds.