High CPU Usage in SwiftUI UIHostingController on iOS 26 Beta

Experiencing 100% CPU usage in SwiftUI app using UIHostingController, only on iOS 26 beta and Xcode beta. Issue involves excessive view updates in AttributeGraph propagation.

Stack trace (main thread):

thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00000001c38b9aa4 AttributeGraph`AG::Graph::propagate_dirty(AG::AttributeID) + 416
    frame #1: 0x00000001d9a743ec SwiftUICore`SwiftUI.ObservationGraphMutation.apply() -> () + 656
    frame #2: 0x00000001d97c0d4c SwiftUICore`function signature specialization <Arg[2] = [Closure Propagated : closure #1 () -> () in SwiftUI.(AsyncTransaction in _F9F204BD2F8DB167A76F17F3FB1B3335).apply() -> (), Argument Types : [SwiftUI.AsyncTransaction]> of generic specialization <()> of closure #1 () throws -> τ_0_0 in SwiftUI.withTransaction<τ_0_0>(SwiftUI.Transaction, () throws -> τ_0_0) throws -> τ_0_0 + 336
    frame #3: 0x00000001d9a6ac80 SwiftUICore`merged function signature specialization <Arg[3] = Owned To Guaranteed> of function signature specialization <Arg[1] = [Closure Propagated : implicit closure #2 () -> () in implicit closure #1 @Sendable (SwiftUI.(AsyncTransaction in _F9F204BD2F8DB167A76F17F3FB1B3335)) -> () -> () in SwiftUI.GraphHost.flushTransactions() -> (), Argument Types : [SwiftUI.AsyncTransaction]> of SwiftUI.GraphHost.runTransaction(_: Swift.Optional<SwiftUI.Transaction>, do: () -> (), id: Swift.Optional<Swift.UInt32>) -> () + 196
    frame #4: 0x00000001d9a52ab0 SwiftUICore`SwiftUI.GraphHost.flushTransactions() -> () + 176
    frame #5: 0x00000001d8461aac SwiftUI`closure #1 (SwiftUI.GraphHost) -> () in SwiftUI._UIHostingView._renderForTest(interval: Swift.Double) -> () + 20
    frame #6: 0x00000001d9bf3b38 SwiftUICore`partial apply forwarder for closure #1 (SwiftUI.ViewGraph) -> τ_1_0 in SwiftUI.ViewGraphRootValueUpdater.updateGraph<τ_0_0>(body: (SwiftUI.GraphHost) -> τ_1_0) -> τ_1_0 + 20
    frame #7: 0x00000001d9e16dc4 SwiftUICore`SwiftUI.ViewGraphRootValueUpdater._updateViewGraph<τ_0_0>(body: (SwiftUI.ViewGraph) -> τ_1_0) -> Swift.Optional<τ_1_0> + 200
    frame #8: 0x00000001d9e1546c SwiftUICore`SwiftUI.ViewGraphRootValueUpdater.updateGraph<τ_0_0>(body: (SwiftUI.GraphHost) -> τ_1_0) -> τ_1_0 + 136
    frame #9: 0x00000001d8461a7c SwiftUI`closure #1 () -> () in closure #1 () -> () in closure #1 () -> () in SwiftUI._UIHostingView.beginTransaction() -> () + 144
    frame #10: 0x00000001d846aed0 SwiftUI`partial apply forwarder for closure #1 () -> () in closure #1 () -> () in closure #1 () -> () in SwiftUI._UIHostingView.beginTransaction() -> () + 20
    frame #11: 0x00000001d984f814 SwiftUICore`closure #1 () throws -> τ_0_0 in static SwiftUI.Update.ensure<τ_0_0>(() throws -> τ_0_0) throws -> τ_0_0 + 48
    frame #12: 0x00000001d984e114 SwiftUICore`static SwiftUI.Update.ensure<τ_0_0>(() throws -> τ_0_0) throws -> τ_0_0 + 96
    frame #13: 0x00000001d846aeac SwiftUI`partial apply forwarder for closure #1 () -> () in closure #1 () -> () in SwiftUI._UIHostingView.beginTransaction() -> () + 64
    frame #14: 0x00000001851eab1c UIKitCore`___lldb_unnamed_symbol311742 + 20
  * frame #15: 0x00000001852b56a8 UIKitCore`___lldb_unnamed_symbol315200 + 44
    frame #16: 0x0000000185175120 UIKitCore`___lldb_unnamed_symbol308851 + 20
    frame #17: 0x00000001d984e920 SwiftUICore`static SwiftUI.Update.dispatchImmediately<τ_0_0>(reason: Swift.Optional<SwiftUI.CustomEventTrace.ActionEventType.Reason>, _: () -> τ_0_0) -> τ_0_0 + 300
    frame #18: 0x00000001d95a7428 SwiftUICore`static SwiftUI.ViewGraphHostUpdate.dispatchImmediately<τ_0_0>(() -> τ_0_0) -> τ_0_0 + 40
    frame #19: 0x00000001852b59dc UIKitCore`___lldb_unnamed_symbol315204 + 192
    frame #20: 0x00000001852b54a4 UIKitCore`___lldb_unnamed_symbol315199 + 64
    frame #21: 0x0000000185745dd4 UIKitCore`_UIUpdateSequenceRunNext + 120
    frame #22: 0x0000000186144fac UIKitCore`schedulerStepScheduledMainSectionContinue + 56
    frame #23: 0x00000002505ad150 UpdateCycle`UC::DriverCore::continueProcessing() + 36
    frame #24: 0x0000000180445b20 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #25: 0x0000000180445a68 CoreFoundation`__CFRunLoopDoSource0 + 168
    frame #26: 0x00000001804451f4 CoreFoundation`__CFRunLoopDoSources0 + 220
    frame #27: 0x00000001804443a8 CoreFoundation`__CFRunLoopRun + 756
    frame #28: 0x000000018043f458 CoreFoundation`_CFRunLoopRunSpecificWithOptions + 496
    frame #29: 0x00000001928d19bc GraphicsServices`GSEventRunModal + 116
    frame #30: 0x0000000186224480 UIKitCore`-[UIApplication _run] + 772
    frame #31: 0x0000000186228650 UIKitCore`UIApplicationMain + 124
    frame #32: 0x000000010bb1b504 MyApp.debug.dylib`main at main.swift:13:1
    frame #33: 0x00000001043813d0 dyld_sim`start_sim + 20
    frame #34: 0x000000010468ab98 dyld`start + 6076

Used let _ = Self.printChanges() in my SwiftUI View and got infinite changes of \_UICornerProvider.<computed 0x000000018527ffd8 (Optional<UICoordinateSpace>)> changed.

Reproduces only on beta; works on stable iOS. Likely beta-specific bug in SwiftUI rendering.

I’m encountering the same issue. Please let me know if you discover any workaround.

I can also see some warnings in console.

Observable object key path '\_UICornerProvider.<computed 0x00000001852600cc (Optional<UICoordinateSpace>)>' changed; performing invalidation for [layout] of: <UILayoutContainerView: 0x104eda520; frame = (0 0; 402 874); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x60000036ef80>; backgroundColor = kCGColorSpaceModelRGB 0.0352941 0.0352941 0.0352941 1; layer = <CALayer: 0x600000e2f660>>

Observation tracking feedback loop detected! Make a symbolic breakpoint at UIObservationTrackingFeedbackLoopDetected to catch this in the debugger. Refer to the console logs for details about recent invalidations; you can also make a symbolic breakpoint at UIObservationTrackingInvalidated to catch invalidations in the debugger. Object receiving repeated [layout] invalidations: <UILayoutContainerView: 0x104eda520; frame = (0 0; 402 874); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x60000036ef80>; backgroundColor = kCGColorSpaceModelRGB 0.0352941 0.0352941 0.0352941 1; layer = <CALayer: 0x600000e2f660>>

I think I have found the cause of the problem. It seems like calling to main window's safe area insets in SwiftUI View causing endless updates. I tried to remove the call and it works fine. But still I don't know how to use it properly then

@Arideno Agreed. I’m working on the fix now.

Solution : Avoid calling UIKit window safe-area insets APIs inside your SwiftUI view body. Instead, get safe-area insets directly from SwiftUI—using a GeometryReader or the safeAreaInset modifier.

I have come up with this singleton that holds the values.

@MainActor
private final class SafeAreaInsetsHolder {
    static let shared = SafeAreaInsetsHolder()
    let topSafeAreaInset: CGFloat
    let bottomSafeAreaInset: CGFloat

    private init() {
        if let window = UIApplication.shared.mainWindow {
            topSafeAreaInset = window.safeAreaInsets.top
            bottomSafeAreaInset = window.safeAreaInsets.bottom
        } else {
            topSafeAreaInset = 0
            bottomSafeAreaInset = 0
        }
    }
}
High CPU Usage in SwiftUI UIHostingController on iOS 26 Beta
 
 
Q