You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
## [56.1.0]
2
-
-Test
2
+
-[LayoutDiagnostics] Added runtime layout diagnostics API for profiling measure/arrange counts per element type. Includes a floating overlay visible over modals and bottom sheets, automatic snapshot capture during page and bottom sheet lifecycle, per-instance thrashing detection, and JSON export.
3
3
4
4
## [56.0.2]
5
5
-[iOS][ItemPicker] Fixed bug where selected item could reset randomly
A runtime diagnostics tool for profiling .NET MAUI layout performance on iOS and Android. It captures per-element **measure** and **arrange** counts during page navigation and bottom sheet presentation, helping developers identify layout thrashing — views that are measured or arranged far more than necessary.
2
+
3
+
# How It Works
4
+
5
+
.NET MAUI's layout system uses a two-phase process for every frame where layout is needed ([source](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/layouts/custom#layout-process)):
6
+
7
+
1.**Measure phase** — The framework calls `IView.Measure()` on each view to determine its desired size given constraints. Layouts call `Measure()` on all their children recursively, bottom-up.
8
+
2.**Arrange phase** — The framework calls `IView.Arrange()` on each view to assign its final position and bounds within the parent layout.
9
+
10
+
These phases can be triggered multiple times per frame. A parent layout may speculatively measure children, change constraints, and re-measure. Deeply nested layouts with complex constraints can cause exponential measure/arrange calls — known as **layout thrashing**.
11
+
12
+
Layout Diagnostics hooks into MAUI's built-in `System.Diagnostics.Metrics` instruments (`maui.layout.measure_count`, `maui.layout.arrange_count`) via `MeterListener` to count every measure and arrange call per element type and instance.
13
+
14
+
# Usage
15
+
16
+
## Prerequisites
17
+
18
+
Register metrics in `MauiProgram.cs`**before**`.UseMauiApp<App>()`:
-`Auto`-sized rows/columns that cause re-measure cascades
77
+
- Changing `IsVisible` or `Text` on elements during layout
78
+
79
+
## Overlay
80
+
81
+
The diagnostics overlay is a floating pill that stays visible over all content, including modals and bottom sheets:
82
+
83
+
-**iOS**: Rendered in a separate `UIWindow` at `UIWindowLevel.Alert - 1`
84
+
-**Android**: Uses `TranslationZ` for z-ordering and re-parents to dialog `DecorView` when dialogs open
85
+
86
+
Tap the pill to expand and see live recording status, start/stop controls, and the current snapshot summary.
87
+
88
+
# Properties
89
+
90
+
Inspect the [`LayoutDiagnosticsService`](https://github.com/DIPSAS/DIPS.Mobile.UI/blob/main/src/library/DIPS.Mobile.UI/API/Diagnostics/LayoutDiagnosticsService.cs) and [`LayoutDiagnosticsSnapshot`](https://github.com/DIPSAS/DIPS.Mobile.UI/blob/main/src/library/DIPS.Mobile.UI/API/Diagnostics/LayoutDiagnosticsSnapshot.cs) classes for the full API surface.
0 commit comments