Skip to content

Fixed nested UIHostingController being added as its own child on iOS 26 - #74

Merged
almazrafi merged 2 commits into
mainfrom
fix/nested-hosting-vc-cycle
Oct 12, 2026
Merged

almazrafi merged 2 commits into
mainfrom
fix/nested-hosting-vc-cycle

Conversation

@timbaev

@timbaev timbaev commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Since #73, ComponentHostingRoot reads the theme via context.componentViewController, i.e. from the environment snapshot of the outer UIViewRepresentable. On iOS 26 this read inside the body of a nested hosting leaks back into that environment: on a repeated update FallbackComponentBody passes the nested UIHostingController to its component, ComponentHostingView adds it as its own child, and UIKit crashes with a stack overflow in -[UIViewController _updateSystemAppearanceWithRecursionBlock:action:].

The view controller for the theme is now taken only from the context overrides, transformEnvironment from #73 is unchanged.

Checks:

  • ComponentHostingNestingTests: fails on iOS 26.5 without the fix, passes on iOS 26.5 and iOS 27.0 with it.
  • An app with a UIKit card hosting SwiftUI content inside SwiftUI ScrollView + LazyVStack: no crash on iOS 26.5, the accessibility hierarchy inside cards is preserved on iOS 27.0.

Since #73, ComponentHostingRoot read the theme via context.componentViewController,
i.e. from the environment snapshot of the outer UIViewRepresentable. On iOS 26
reading it in the body of a nested hosting leaks back into that environment:
on a repeated update the parent component receives the nested UIHostingController
in its context, adds it as its own child, and UIKit crashes with a stack overflow.

The view controller for the theme is now taken only from the context overrides.
Added ComponentHostingNestingTests: it fails on iOS 26.5 without the fix
and passes on iOS 27.
@steve-jobs-bot

Copy link
Copy Markdown
12 Warnings
⚠️ Sources/Misc/ViewArrayBuilder.swift#L3 - TODOs should be resolved (Добавить документацию)
todo ViewArrayBuilder.swift:3
⚠️ Sources/Misc/ViewBindable.swift#L3 - TODOs should be resolved (Добавить документацию)
todo ViewBindable.swift:3
⚠️ Sources/Misc/ViewBinding.swift#L4 - TODOs should be resolved (Добавить документацию)
todo ViewBinding.swift:4
⚠️ Sources/Misc/ViewEnvironment.swift#L3 - TODOs should be resolved (Добавить документацию)
todo ViewEnvironment.swift:3
⚠️ Sources/Misc/ViewFocusBinding.swift#L3 - TODOs should be resolved (Добавить документацию)
todo ViewFocusBinding.swift:3
⚠️ Sources/Misc/ViewFocusState.swift#L3 - TODOs should be resolved (Добавить документацию)
todo ViewFocusState.swift:3
⚠️ Sources/Misc/ViewFocusState.swift#L14 - TODOs should be resolved (Перенести наработки из проекта…)
todo ViewFocusState.swift:14
⚠️ Sources/Token/Presentation/UIKit/Properties/Extensions/TokenViewProperties+UINavigationBar.swift#L54 - TODOs should be resolved (implement for appearance)
todo TokenViewProperties+UINavigationBar.swift:54
⚠️ Sources/Token/Presentation/UIKit/Properties/Extensions/TokenViewProperties+UITabBar.swift#L36 - TODOs should be resolved (implement for appearance)
todo TokenViewProperties+UITabBar.swift:36
⚠️ Sources/Token/Presentation/UIKit/Properties/Extensions/TokenViewProperties+UIToolbar.swift#L31 - TODOs should be resolved (implement for appearance)
todo TokenViewProperties+UIToolbar.swift:31
⚠️ Sources/Token/Value/Typography/TypographyValue.swift#L24 - TODOs should be resolved (Удалить после миграции в проек…)
todo TypographyValue.swift:24
⚠️ Sources/Tools/Extensions/UIKit/UIImage+Extensions.swift#L7 - Sources/Tools/Extensions/UIKit/UIImage+Extensions.swift#L7: 'default()' was deprecated in tvOS 11.0
2 Messages
📖 Levitan Tests iOS: Executed 1 test, with 0 failures (0 expected) in 1.944 (1.944) seconds
📖 Levitan Tests tvOS: Executed 0 tests, with 0 failures (0 expected) in 0 (0.0) seconds

Generated by 🚫 Danger

@almazrafi
almazrafi merged commit 86aa6a0 into main Oct 12, 2026
3 checks passed
@almazrafi
almazrafi deleted the fix/nested-hosting-vc-cycle branch October 12, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants