Menu

Fixing a streaming SwiftUI chat hang: stable scroll anchors and local/cloud cancellation
📰

Fixing a streaming SwiftUI chat hang: stable scroll anchors and local/cloud cancellation

DEV Community: swift·Greg Young·12 days ago
#Tx7SsCLy
#devtoswift#devto#dev#exchange#answer
Reading 0:00
15s threshold

In a SwiftUI reference app, streamed model output and illustrated answer cards repeatedly change the transcript’s height. The assistant uses Apple Foundation Models when available, with a consent-controlled online fallback. A reproduced layout hang led to changes in both rendering and task lifetime.

The failure

Opening “Ask guide” from an entry could leave the process hung at roughly 99% CPU. The sampled main thread repeatedly hit SwiftUI lazy-stack placement/graph updates, and the observed process footprint reached 1.1 GB. Reopening returned to the same hung process. A UI reproduction also timed out while querying the app.

The transcript combined lazy height estimation, a scroll target on a growing answer, animated scrolling, and frequent streamed-text updates.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.