Articles Projects About Subscribe
All posts
Saurabh Dave
Swift · SwiftUI · Apple Platform · Sep 10, 2026
Post

Real-time SwiftUI can stutter under bursty feeds due to unbounded buffers, main-actor hot paths, or tasks that outlive their owners. Model each live source as an AsyncSequence with explicit buffering, cancellation, and isolation.

  • Expose feeds via AsyncStream/AsyncThrowingStream with .bufferingOldest(N); call finish() on teardown and test โ€œno emit after cancel.โ€
  • Consume in views with task(id:); keep mutations on the @MainActor and check Task.isCancelled inside loops.
  • Bridge delegates and legacy publishers at repository boundaries into AsyncStream so views subscribe to one model.
  • Coalesce and parse off-main; hop back only for UI. Add OSSignposter around parse โ†’ diff โ†’ render to spot stalls.
  • ๐Ÿงช Add async tests for cancel-after-start and run burst scenarios in Instruments;
#iOS#Swift#SwiftUI#iOSArchitecture#SoftwareArchitecture