Skip to content

Commit bedd1b1

Browse files
[iOS] SafeArea: Skip initial connection invalidation (#37841)
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ## Description Skips `InvalidateMeasure` from the iOS/Mac Catalyst `SafeAreaEdges` mapper while a new handler is connecting. The initial layout pass already reads the current safe-area value. Reconnects and dynamic `SafeAreaEdges` changes retain the existing invalidation behavior. ## Benchmark The local Sandbox harness is not included in this PR. Release iOS simulator, iPhone 16 Pro / iOS 18.4: | Metric | Result | |---|---:| | Heavy tile `ToPlatform` (55 elements) | 12.841 ms | | Flat tile `ToPlatform` (14 elements) | 4.735 ms | | `SafeAreaEdges` mapper calls | 480 | | `SafeAreaEdges` mapper total | <0.3 ms | The attribution count includes mapper entries that return immediately. This micro-optimization is below end-to-end simulator noise and no aggregate speedup is claimed. The run completed all 70 benchmark results with `run-end|ok`. ## Review Independent GPT, Claude, and Gemini reviews traced the exact `Connecting` / `Reconnecting` state flags, initial parent attachment, non-default values, dynamic updates, and iOS/Mac Catalyst layout-time safe-area reads. All three found the initial invalidation redundant and the guard safe. Copilot-Session: 5a03e13d-1a41-4652-a8c6-099eeb79cd50
1 parent 92dfb49 commit bedd1b1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Core/src/Handlers/View/ViewHandler.iOS.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ internal static void UpdateTransformation(IViewHandler handler, IView view)
154154

155155
internal static void MapSafeAreaEdges(IViewHandler handler, IView view)
156156
{
157+
if (handler.IsConnectingHandler())
158+
{
159+
return;
160+
}
161+
157162
view.InvalidateMeasure();
158163
}
159164
}

0 commit comments

Comments
 (0)