Repository navigation
iOS: a route a stack is given borrows its insets until UIKit places it - #2500
Merged
Merged
Conversation
Why === On an open iPhone Duo, choosing UI Gallery's Text colors beside Typography for the first time drew its first frame with its paragraphs broken across the 84 pt side strip, then wrapped inside it a frame later. The new route's content was laid out before UIKit placed its controller, with no local insets: its sections pad their scrollers with `var(--exact-safe-area-inset-*)` (LLP 1123 D9), and `reportLocalInsets` reports a route's only once its view is in a window. The split writes the detail only after the route's header is lifted into the bar, a covers pass later, and UIKit gives the route its safe area as it places it, so the kernel laid the content out at the wrong width first, painted its text there, and laid it out again; the text's rasters for the right width came a frame after the boxes moved. How === `prepareRoutes` records on each route the stack the router gave it (`RouteController.arriving`). Until UIKit places it there, `reportLocalInsets` gives the route the local insets of the route that stack shows, which are its column's and the safe area UIKit gives it, so the content lays out where it will rest. `LocalInsetsReport.borrowed` keeps those apart from a report of UIKit's own, so the route's first measure still takes its landing safe area, as a route with no report does. Test Plan ========= On the open iPhone Duo simulator (iOS 27.1), UI Gallery driven with `bun scripts/agent.mjs ios --app ui-gallery --chrome platform --timing platform`, Typography then Text colors, filmed with `simctl io recordVideo` in three runs: the first frame of Text colors has its paragraphs and its swatches' samples where they rest, and nothing in the detail moves after it. A probe build showed the content laid out at its final width in the covers pass before UIKit places the route, its text painted once at that width as it appears, and no width change from UIKit's measure. `perf during "tap sidebar-textcolors"` counts 814 node layouts where it counted about 1,400 to 1,540, and 7 kernel layouts, as before. `bun host/apple/build.mjs --test --ios --only LocalInsetsIOSTests,SplitIOSTests,ScrollInsetsIOSTests` passes but for `SplitIOSTests.testAnInstallTheRunnerCannotAnswerAsksAgain`, which fails on main too. `bun scripts/gate.mjs` passes. No test of its own: a hosted XCTest loses the Duo's hinge, and a window larger than the screen gives the detail other insets than the open Duo does, so the case is verified on the simulator as above.
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.
Why
On an open iPhone Duo, choosing UI Gallery's Text colors beside Typography for the first time drew its first frame with its paragraphs broken across the 84 pt side strip, then wrapped inside it a frame later. The new route's content was laid out before UIKit placed its controller, with no local insets: its sections pad their scrollers with
var(--exact-safe-area-inset-*)(LLP 1123 D9), andreportLocalInsetsreports a route's only once its view is in a window. The split writes the detail only after the route's header is lifted into the bar, a covers pass later, and UIKit gives the route its safe area as it places it, so the kernel laid the content out at the wrong width first, painted its text there, and laid it out again; the text's rasters for the right width came a frame after the boxes moved.How
prepareRoutesrecords on each route the stack the router gave it (RouteController.arriving). Until UIKit places it there,reportLocalInsetsgives the route the local insets of the route that stack shows, which are its column's and the safe area UIKit gives it, so the content lays out where it will rest.LocalInsetsReport.borrowedkeeps those apart from a report of UIKit's own, so the route's first measure still takes its landing safe area, as a route with no report does.Test Plan
On the open iPhone Duo simulator (iOS 27.1), UI Gallery driven with
bun scripts/agent.mjs ios --app ui-gallery --chrome platform --timing platform, Typography then Text colors, filmed withsimctl io recordVideoin three runs: the first frame of Text colors has its paragraphs and its swatches' samples where they rest, and nothing in the detail moves after it. A probe build showed the content laid out at its final width in the covers pass before UIKit places the route, its text painted once at that width as it appears, and no width change from UIKit's measure.perf during "tap sidebar-textcolors"counts 814 node layouts where it counted about 1,400 to 1,540, and 7 kernel layouts, as before.bun host/apple/build.mjs --test --ios --only LocalInsetsIOSTests,SplitIOSTests,ScrollInsetsIOSTestspasses but forSplitIOSTests.testAnInstallTheRunnerCannotAnswerAsksAgain, which fails on main too.bun scripts/gate.mjspasses. No test of its own: a hosted XCTest loses the Duo's hinge, and a window larger than the screen gives the detail other insets than the open Duo does, so the case is verified on the simulator as above.