@Shared can trigger a view update from a thread other than the main thread, which sometimes causes crash #3182
Replies: 2 comments 5 replies
-
Hi @larryonoff, this will be fixed in #3178 when we require that |
Beta Was this translation helpful? Give feedback.
-
A new source of the issue has been identified. A crash occurs in production when the The following entry was recorded in Crashlytics:
sample from our code public func subscribe(
initialValue: Purchases?,
didSet: @escaping (Purchases?) -> Void
) -> Shared<Purchases>.Subscription {
let task = Task {
for await purchases in self.purchases.purchasesUpdates() {
didSet(purchases)
// looks that possible solution is wrapping didSet into MainActor
// await MainActor.run { didSet(purchases) }
// or Task { @MainActor in
}
}
return Shared.Subscription {
task.cancel()
}
} |
Beta Was this translation helpful? Give feedback.
-
Description
There’s an issue where updating
@Shared
from a thread other than the main thread triggers a warning during debugging and sometimes causes crashes in the release configuration.Checklist
main
branch of this package.Expected behavior
Crashes or warnings do not occur
Actual behavior
Crashlytics reports occasional crashes. Xcode shows warnings during debugging.
Steps to reproduce
Refer to the sample project
The Composable Architecture version information
1.11.1
Destination operating system
iOS 17.5.1
Xcode version information
Version 15.4 (15F31d)
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions