Post

Replies

Boosts

Views

Activity

Reply to Any SwiftData change updates every SwiftUI view
Thank you for confirming the behavior. It became a problem for me because my app is constructing a complex view model from my data model, and the frequent updates were using a lot of CPU on the main thread. Fixing the issue wasn't easy, but I managed it through a combination of design changes: My model objects cache the view model in a @Transient field. My data models notify the view models of changes. The view models provide a CurrentValueSubject for each relevant data property that publishes changes to that property. The view models perform their calculations in the background by subscribing to changes in other view models. The view models are also @Observable, and they modify an observable property when the result of a calculation changes. My SwiftUI views observe the view models for changes. It was a lot of work to reorganize the code this way, but the app is now performing UI updates only when the relevant data changes, and most of the work is done in the background.
Feb ’25
Reply to Alternative for crashing API MPMediaItemArtwork
I ran into this myself and can confirm that marking the block @Sendable fixes the crash. I believe the problem is that the SDK doesn't require the block to be @Sendable, which it should. The MPNowPlayingInfoCenter is executing that block on an internal dispatch queue. If you call the constructor from an actor-isolated function, the block is also actor-isolated by default, and the now-playing center crashes trying to call the actor-isolated block.
Topic: Media Technologies SubTopic: Video Tags:
Feb ’25