[BugFix][iOS] Avoid host orientation recursion - #129
Open
Huxpro wants to merge 1 commit into
Open
Conversation
- Read orientation from the navigation stack top controller for every host type. - Fall back to the Sparkling controller base policy when the stack has no top controller. - Cover a non-Sparkling host controller to prevent delegate recursion. TEST: SparklingGoTests passed 337 tests in 20 suites on iOS Simulator. Co-authored-by: TRAE CLI <noreply@bytedance.com>
dirtmelon
requested review from
LittleGru and
dirtmelon
and
a lite review from Copilot
August 11, 2026 04:02
There was a problem hiding this comment.
Pull request overview
Fixes an iOS navigation-controller orientation regression in Sparkling by changing how SPKViewController (as a UINavigationControllerDelegate) derives supported/preferred interface orientations, preventing recursive delegate re-entry and main-thread stack overflow when a non-Sparkling controller is on top of a Sparkling-owned navigation stack.
Changes:
- Update
UINavigationControllerDelegateorientation callbacks to use the navigation stack’s actualtopViewControllerorientation properties (avoiding calling back intoUINavigationController). - Add a new router test covering the “non-Sparkling top controller” scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/sparkling-sdk/ios/Sparkling/Sources/Application/Container/SPKViewController.swift | Adjusts orientation delegate methods to avoid recursive fallback and use the actual top VC as the policy source. |
| packages/playground/ios/SparklingGoTests/Application/SPKRouterTests.swift | Adds test coverage for a navigation stack where the top controller is not Sparkling-owned. |
Suppressed comments (1)
packages/sparkling-sdk/ios/Sparkling/Sources/Application/Container/SPKViewController.swift:1133
- Same issue as above for preferred orientation: falling back to
super.preferredInterfaceOrientationForPresentationbypassesSPKViewController.preferredInterfaceOrientationForPresentation(which appliesSPKContext.interfaceOrientationPolicy). Useself.preferredInterfaceOrientationForPresentationas the safe fallback when the navigation stack is empty.
return navigationController.topViewController?
.preferredInterfaceOrientationForPresentation
?? super.preferredInterfaceOrientationForPresentation
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1124
to
+1125
| return navigationController.topViewController?.supportedInterfaceOrientations | ||
| ?? super.supportedInterfaceOrientations |
Comment on lines
+129
to
+142
| let delegate = SPKViewController( | ||
| withURL: nil, | ||
| config: SPKSchemeParam(), | ||
| context: SPKContext(), | ||
| frame: .zero) | ||
| let host = HostViewController() | ||
| let navigationController = UINavigationController(rootViewController: host) | ||
|
|
||
| #expect( | ||
| delegate.navigationControllerSupportedInterfaceOrientations( | ||
| navigationController) == .portraitUpsideDown) | ||
| #expect( | ||
| delegate.navigationControllerPreferredInterfaceOrientationForPresentation( | ||
| navigationController) == .portraitUpsideDown) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UINavigationControllerfor the same delegate-owned policySPKViewControllerRegression
A Sparkling-owned navigation stack can later present a non-Sparkling tooling controller. The previous fallback called
navigationController.supportedInterfaceOrientationsfrom the navigation delegate itself, recursively re-entering the same callback until the main-thread stack overflowed.Validation
SparklingGoTests: 337 tests in 20 suites passed on iOS SimulatorStack