Skip to content

Commit 841d7c9

Browse files
committed
Cite Apple's documentation for the layout-time region read
UIView.ReservedRegion documents that UIKit tracks the regions read in updateConstraints() and runs it again when they change, and the automatic observation tracking page lists viewDidLayoutSubviews among the tracked methods. The comments at the read site and on refresh now point to both.
1 parent a7ae4e0 commit 841d7c9

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

‎engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDisplayFeatures.h‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,15 @@ API_AVAILABLE(ios(27.1))
110110
///
111111
/// This must be called from the view controller's `viewDidLayoutSubviews`.
112112
/// Reserved regions lag the hinge, and UIKit offers no notification for them;
113-
/// instead it tracks a read made during layout and runs layout again when the
114-
/// region changes. Measured on the iPhone Duo simulator: with the read inside
113+
/// instead a read made during layout is tracked, and UIKit runs layout again
114+
/// when the region changes. Apple documents this for `updateConstraints`
115+
/// ("UIKit tracks the regions you read in updateConstraints() and runs it
116+
/// again when they change"):
117+
/// https://developer.apple.com/documentation/uikit/uiview/reservedregion
118+
/// and lists `viewDidLayoutSubviews` among the methods with automatic
119+
/// observation tracking:
120+
/// https://developer.apple.com/documentation/uikit/automatic-observation-tracking
121+
/// Measured on the iPhone Duo simulator: with the read inside
115122
/// `viewDidLayoutSubviews`, a layout pass follows every change of the division
116123
/// (about a second after the hinge reads partially open, and within 15 ms of
117124
/// it reading fully open). With the read made only outside layout, no layout

‎engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,11 +1379,19 @@ - (void)viewDidLayoutSubviews {
13791379
[self checkAndUpdateAutoResizeConstraints];
13801380
[self setViewportMetricsPaddings];
13811381
if (@available(iOS 27.1, *)) {
1382-
// This read has to happen during layout. Reserved regions lag the hinge and
1383-
// UIKit has no notification for them; it tracks a read made here and runs
1384-
// layout again when a region changes, which is the only signal there is
1385-
// while folding, since the view's bounds stay the same. A change of hinge
1386-
// posture requests a pass too, so this is the only place regions are read.
1382+
// This read has to happen during layout. Reserved regions lag the hinge
1383+
// and UIKit has no notification for them. Instead, a region read made in
1384+
// viewDidLayoutSubviews is tracked, and UIKit runs layout again when that
1385+
// region changes. Apple documents the tracking for updateConstraints
1386+
// ("UIKit tracks the regions you read in updateConstraints() and runs it
1387+
// again when they change"):
1388+
// https://developer.apple.com/documentation/uikit/uiview/reservedregion
1389+
// and lists viewDidLayoutSubviews among the methods with automatic
1390+
// observation tracking:
1391+
// https://developer.apple.com/documentation/uikit/automatic-observation-tracking
1392+
// That pass is the only signal there is while folding, since the view's
1393+
// bounds stay the same. A change of hinge posture requests a pass too, so
1394+
// this is the only place regions are read.
13871395
[_displayFeaturesMonitor refresh];
13881396
}
13891397
[self updateViewportMetricsIfNeeded];

0 commit comments

Comments
 (0)