fix: Avoid recursive view loading - #8941
Merged
Merged
Conversation
Use viewIfLoaded while identifying full-screen container children so relevant view controller traversal cannot re-enter a parent's loadView. Cover the swizzled tracing path with a regression test that verifies viewDidLoad runs once when a loaded navigation child belongs to an unloaded parent.
philprime
marked this pull request as ready for review
September 3, 2026 15:22
philprime
requested review from
NinjaLikesCheez,
itaybre and
noahsmartin
as code owners
September 3, 2026 15:22
📲 Install BuildsiOS
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d244305 | 1217.61 ms | 1249.51 ms | 31.90 ms |
| b524775 | 1220.17 ms | 1244.51 ms | 24.34 ms |
| c34c99b | 1220.10 ms | 1259.33 ms | 39.22 ms |
| bbb8fdc | 1227.79 ms | 1258.28 ms | 30.49 ms |
| 4d32b0c | 1216.38 ms | 1255.98 ms | 39.60 ms |
| 96e2288 | 1205.88 ms | 1234.78 ms | 28.90 ms |
| b5f0d9a | 1227.05 ms | 1254.18 ms | 27.13 ms |
| 89c6f79 | 1215.43 ms | 1256.32 ms | 40.89 ms |
| fc4e913 | 1221.61 ms | 1253.82 ms | 32.21 ms |
| 809b6b3 | 1222.13 ms | 1264.55 ms | 42.43 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d244305 | 24.14 KiB | 1.30 MiB | 1.28 MiB |
| b524775 | 24.14 KiB | 1.24 MiB | 1.21 MiB |
| c34c99b | 24.14 KiB | 1.29 MiB | 1.27 MiB |
| bbb8fdc | 24.14 KiB | 1.17 MiB | 1.14 MiB |
| 4d32b0c | 24.14 KiB | 1.25 MiB | 1.23 MiB |
| 96e2288 | 24.14 KiB | 1.31 MiB | 1.29 MiB |
| b5f0d9a | 24.14 KiB | 1.24 MiB | 1.21 MiB |
| 89c6f79 | 24.14 KiB | 1.29 MiB | 1.27 MiB |
| fc4e913 | 24.14 KiB | 1.17 MiB | 1.15 MiB |
| 809b6b3 | 24.14 KiB | 1.31 MiB | 1.29 MiB |
philprime
enabled auto-merge (squash)
September 4, 2026 08:26
NinjaLikesCheez
approved these changes
Sep 4, 2026
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.
📜 Description
Prevent relevant view controller traversal from loading views while checking whether a child container fills its parent. The traversal now uses
viewIfLoadedfor both controllers instead of readingchildVC.viewandtopVC.view.This keeps Sentry's tracing instrumentation from recursively entering an unloaded parent view controller's
loadViewand invokingviewDidLoadtwice.💡 Motivation and Context
A reported production crash showed a view controller executing
viewDidLoadtwice while Sentry tracing was enabled. The second invocation caused FluentUI to register the same token observer twice and fail withAttempting to double-register for tokenSet updates!.This is a variant of #3753. That fix guarded only
childVC.isViewLoaded. When the child navigation controller was already loaded but its parent was not, comparing its frame againsttopVC.view.boundsstill loaded the parent recursively during Sentry's swizzledloadViewpath.The regression test recreates that hierarchy with an unloaded parent and a loaded child navigation controller. Before the fix, it observed two
viewDidLoadinvocations. With the fix, it observes one.💚 How did you test it?
viewDidLoadran twice instead of once.SentryUIViewControllerSwizzlingTestssuccessfully.make format.make analyzesuccessfully.make build-ios FOR_AGENTS=truesuccessfully.📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.