Repository navigation
[Windows]Fix: Label Formatted Text crashed with out of memory Exception - #36828
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36828Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36828" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
Hey there @@SubhikshaSf4851! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
kubaflo
left a comment
There was a problem hiding this comment.
Is this one ready for review?
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-specific Label.FormattedText crash/hang caused by an infinite loop in FormattedStringExtensions.RecalculateSpanPositions when cached MeasuredLineHeight is 0 after measuring while hidden/collapsed. It also adds a Windows device test to cover the “set formatted text while hidden, then show” scenario.
Changes:
- Add a guard in
RecalculateSpanPositionsto avoid infinite growth oflineHeightswhen computed line height is<= 0. - Add a Windows device test which sets
FormattedTextwhileIsVisible=falseand then shows the label to ensure no hang/crash occurs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Controls/src/Core/Platform/Windows/Extensions/FormattedStringExtensions.cs | Adds a safety guard to prevent infinite looping/OOM during span region calculation when line height is invalid. |
| src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Windows.cs | Adds a Windows device test to validate that showing a hidden label with formatted text does not hang/crash. |
|
/review -b improved-reviewer -p catalyst |
…drops a /review The trigger-review job did a FULL clone of the large dotnet/maui repo with only the job's 10-min timeout to stop it. A transient network stall on that clone made the "Checkout repository scripts" step hang until the JOB timeout CANCELLED the whole job — silently, because a cancellation skips the downstream steps (no pipeline queued, no notice). Observed repeatedly: #35640, and #36828 (trigger run 30647459829 cancelled at "Checkout repository scripts"). - Shallow the checkout (fetch-depth: 1) — this job only needs .github/scripts, so it now completes in seconds instead of cloning full history. - Add a per-step timeout-minutes: 4 (< the job's 10) so a rare stall becomes a proper step FAILURE that runs the cleanup/notice steps, instead of a job-level cancellation. - Add a cancelled()/failure() notice step that posts a "transient infra — re-comment /review" warning using gh + the event payload directly (no repo scripts, which may be exactly what failed to check out), so a checkout hang is never silent again. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 15d2af20-e4ab-4e88-9011-cfbd83513bc0
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…drops a /review The trigger-review job did a FULL clone of the large dotnet/maui repo with only the job's 10-min timeout to stop it. A transient network stall on that clone made the "Checkout repository scripts" step hang until the JOB timeout CANCELLED the whole job — silently, because a cancellation skips the downstream steps (no pipeline queued, no notice). Observed repeatedly: #35640, and #36828 (trigger run 30647459829 cancelled at "Checkout repository scripts"). - Shallow the checkout (fetch-depth: 1) — this job only needs .github/scripts, so it now completes in seconds instead of cloning full history. - Add a per-step timeout-minutes: 4 (< the job's 10) so a rare stall becomes a proper step FAILURE that runs the cleanup/notice steps, instead of a job-level cancellation. - Add a cancelled()/failure() notice step that posts a "transient infra — re-comment /review" warning using gh + the event payload directly (no repo scripts, which may be exactly what failed to check out), so a checkout hang is never silent again. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 15d2af20-e4ab-4e88-9011-cfbd83513bc0
This comment has been minimized.
This comment has been minimized.
AI Review Summary
🗂️ Review Sessions — click to expand🚦 Gate — Test Before & After FixGate Result:
|
| Test | Without Fix (expect FAIL) | With Fix (expect PASS) |
|---|---|---|
📱 LabelTests (FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden) Category=Label |
🔴 Without fix — 📱 LabelTests (FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden): ⚠️ ENV ERROR · 325s
No log file found
🟢 With fix — 📱 LabelTests (FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden): ⚠️ ENV ERROR · 185s
No log file found
⚠️ Failure Details
⚠️ LabelTests (FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden) without fix:Windows device test result file 'artifacts\log\TestResults-Microsoft_Maui_Controls_DeviceTests_Label.xml' is empty or not valid XML (the device-test app likely crashed or exited before writing results).⚠️ LabelTests (FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden) with fix:Windows device test result file 'artifacts\log\TestResults-Microsoft_Maui_Controls_DeviceTests_Label.xml' is empty or not valid XML (the device-test app likely crashed or exited before writing results).
📁 Fix files reverted (1 files)
src/Controls/src/Core/Platform/Windows/Extensions/FormattedStringExtensions.cs
📱 UI Tests — Label
Detected UI test categories: Label
✅ Deep UI tests — 91 passed, 0 failed across 1 category on platform-pool agent (replaces in-process counts above).
🧪 UI Test Execution Results (deep, platform pool)
| Category | Tests | Snapshot diffs |
|---|---|---|
Label |
91/94 ✓ | — |
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs) |
📋 Pre-Flight — Context & Validation
Issue: #35527 - Label with FormattedText crashes with OutOfMemoryException in RecalculateSpanPositions on Windows when text exceeds ~150 characters
PR: #36828 - [Windows]Fix: Label Formatted Text crashed with out of memory Exception
Platforms Affected: Windows
Files Changed: 1 implementation, 1 test
Key Findings
- Windows
Label.FormattedTextcan hang/OOM inFormattedStringExtensions.RecalculateSpanPositionswhen a hidden/collapsedTextBlockcachesMeasuredLineHeight == 0and later recalculates wrapped span positions. - PR fix adds a
lineHeight <= 0break, which stops the infinite loop but can leave partiallineHeightsand assign an incompleteRegionfor wrapped spans. - Existing regression test verifies no hang/crash but does not verify span region/hit-test correctness after the label is shown.
- Prior inline feedback raised the same partial-region risk; author replied that no change was needed, and the current diff still contains the
breakpath.
Code Review Summary
Verdict: NEEDS_CHANGES
Confidence: low
Errors: 1 | Warnings: 1 | Suggestions: 0
Key code review findings:
- ✗
src/Controls/src/Core/Platform/Windows/Extensions/FormattedStringExtensions.cs:238—breakcan truncate multi-line span hit-test regions by preserving a partiallineHeightslist and still assigningRegion.FromLines(...). - ⚠
src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Windows.cs:79— test proves no hang but not that span regions remain correct.
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #36828 | Break out of line-height accumulation when a computed line height is <= 0. |
src/Controls/src/Core/Platform/Windows/Extensions/FormattedStringExtensions.cs, src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Windows.cs |
Original PR; prevents OOM but may leave incomplete span regions. |
🔬 Code Review — Deep Analysis
Code Review — PR #36828
Independent Assessment
What this changes: Adds a Windows Label.FormattedText span-position guard that breaks out of line-height accumulation when computed line height is <= 0, plus a Windows device test for showing a hidden formatted label.
Inferred motivation: Avoid an infinite loop/OOM when MeasuredLineHeight was cached as 0 while the TextBlock was hidden/collapsed.
Reconciliation with PR Narrative
Author claims: Fixes Windows OOM/hang for hidden/long formatted labels and adds coverage.
Agreement/disagreement: The guard prevents the infinite loop, but it can still assign an incomplete span region, so the fix is not complete for interactive formatted spans.
Prior Review Reconciliation
| Prior ❌ Error Finding | Source | Status | Evidence |
|---|---|---|---|
break can leave lineHeights incomplete and produce undersized hit-test regions for multi-line spans. |
Copilot inline review / MauiBot summary | ❌ Unresolved | Current code still breaks at FormattedStringExtensions.cs:238-240 and still calls Region.FromLines(lineHeights...) at lines 247-253 with the partial list. Author replied “No changes needed,” but no code changed. |
Blast Radius Assessment
- Runs for all instances: Yes — every Windows formatted
Labelrecalculates span regions during arrange. - Startup impact: No direct startup impact; runs during layout/arrange.
- Static/shared state: No new static state.
- Platform/UI plumbing: Yes — Windows text/span hit-testing layout.
CI Status
- Required-check result: undetermined —
gh pr checks 36828 --repo dotnet/maui --requiredfailed because GitHub CLI is unauthenticated. - Classification: undetermined. Public check-runs on the head SHA also show
Build Analysisandmaui-pr-uitestsfailures/in-progress, whilemaui-prpassed. - Action taken: confidence capped low.
Findings
❌ Error — Guard can truncate multi-line span hit-test regions
src/Controls/src/Core/Platform/Windows/Extensions/FormattedStringExtensions.cs:238
The new guard stops the infinite loop, but break preserves any partial lineHeights collected and still assigns that partial region to the span. If a hidden formatted label caches MeasuredLineHeight = 0, then after showing, a wrapped span can record only the first visual line, break on the middle-line branch, and create a single-line Region. Taps/gestures on later wrapped lines can miss.
⚠️ Warning — Regression test only proves no hang
src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Windows.cs:79
The test waits for completion but does not assert that span regions remain correct after showing the label. This allows the partial-region regression above to pass.
External Output Contract
| Consumer token/pattern | Producer location | Producer emission condition | Consumer assumption | Ordinary negative case | Downstream effect |
|---|---|---|---|---|---|
| N/A | N/A | No changed code classifies external tool output. | N/A | N/A | N/A |
Failure-Mode Probing
- Hidden multi-line span with tap recognizer: no OOM, but later wrapped lines can be outside the assigned
Region. - Non-interactive formatted text: rendering may look fine, masking the hit-test regression.
- Handler/layout reconnect: arrange recalculates, but stale
MeasuredLineHeight == 0repeats the truncated-region path.
Verdict: NEEDS_CHANGES
Confidence: low (Windows platform UI plumbing plus CI status undetermined; confidence in the specific defect is high.)
Summary: The PR addresses the OOM symptom but leaves a concrete correctness bug for wrapped formatted spans with gestures. The unresolved prior ❌ finding also requires NEEDS_CHANGES.
🛠️ Fix — Analysis & Comparison
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| 1 | try-fix-1 | Substitute a positive fallback line height inside RecalculateSpanPositions instead of breaking when cached/middle line height is non-positive. |
1 file | Build succeeded; Windows device-test result parser crashed. Preserves wrapped span regions better than PR, but still handles poisoned cache in the arrange loop. | |
| 2 | try-fix-2 | Prevent FindDefaultLineHeight from caching zero by returning a positive font-metric fallback for hidden/collapsed TextBlocks; remove PR's arrange-time break. |
2 files | Build succeeded and Label category did not hang; result parser crashed. Strongest candidate: root-cause fix, complete regions, fewer arrange-loop branches. | |
| 3 | try-fix-3 | On invalid line geometry, build conservative fallback rectangles instead of calling Region.FromLines with partial line heights. |
1 file | Build succeeded; result parser crashed. Self-review found moderate over-match risk for multiple gesture spans. | |
| 4 | try-fix-4 | Skip region update when line geometry is invalid so partial data is not published. | 1 file | Build succeeded; result parser crashed. Self-review found moderate stale/default region risk for span hit-testing. | |
| PR | PR #36828 | Break out of line-height accumulation when computed line height is <= 0. |
2 files | Original PR prevents OOM but can assign partial span regions. |
Cross-Pollination
| Model | Round | New Ideas? | Details |
|---|---|---|---|
| claude-opus-4.6 | 1 | Yes | Positive fallback line-height strategy (implemented as try-fix-1). |
| claude-opus-4.7 | 1 | Yes | Fix zero cached default line height at FindDefaultLineHeight (implemented as try-fix-2). |
| gpt-5.3-codex | 1 | Yes | Conservative fallback region on invalid geometry (implemented as try-fix-3); moderate over-match risk found. |
| gpt-5.5 | 1 | Yes | Geometry deferral/no partial region update (implemented as try-fix-4); moderate stale/default region risk found. |
| claude-opus-4.6 | 2 | Yes | One-shot LayoutUpdated/dispatcher retry after valid layout. Not run: a retry alone still reuses the poisoned zero MeasuredLineHeight cache, so it degenerates into stale/no region or repeated retries unless combined with try-fix-2's cache fix. |
| claude-opus-4.7 | 2 | Yes | Replace inferred line-height accumulation with authoritative TextLayout/TextLine metrics. Not run: WinUI TextBlock does not expose a simple per-line text layout API in this call path; implementing a parallel text layout engine would be a broad refactor, not a focused candidate. |
| gpt-5.3-codex | 2 | No | Remaining ideas are trivial recombinations of symptom guards or the cache fix. |
| gpt-5.5 | 2 | Yes | Defer region recomputation until visible layout and clear/preserve no region while hidden. Not run separately because this is the same family as try-fix-4 plus the same poisoned-cache limitation as the layout retry idea. |
Exhausted: Yes
Selected Fix: Candidate #2 (try-fix-2) — best blocked candidate. It fixes the zero line-height cache at the source, removes the PR's partial-region break, preserves complete multi-line span regions, and avoids adding work to the arrange hot path. It could not be declared passing because the Windows device-test result parser failed after execution, the same environment blocker seen across all candidates.
📝 Recommended PR Title & Description
Assessment: ✏️ Recommend updating — the current metadata accurately describes the raw PR, but the winning fix moves the core guard from RecalculateSpanPositions to FindDefaultLineHeight, so the title/description should describe the root-cause cache fix and preserved span regions.
Recommended title
[Windows] Label: Prevent zero formatted-text line heights while hidden
Recommended description
This pull request addresses a critical Windows bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`.
### Description of Change:
**Bug fix for line height calculation:**
* Prevents `TextBlockExtensions.FindDefaultLineHeight` from caching a zero or negative `MeasuredLineHeight` when a `TextBlock` is measured while hidden/collapsed.
* Falls back to a positive font-size-based line-height estimate when WinUI measurement returns `DesiredSize.Height <= 0`, so `FormattedStringExtensions.RecalculateSpanPositions` can continue producing complete wrapped span regions.
* Avoids the downstream partial-region behavior caused by breaking out of `RecalculateSpanPositions` after only some line heights have been collected.
**Testing improvements:**
* Added a Windows device test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI.
* Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test.
### Issues Fixed
Fixes #35527
### Tested the behavior in the following platforms
- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac
| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> |
🏁 Report — Final Recommendation
Comparative Candidate Report — PR #36828
Summary
Winning candidate: pr-plus-reviewer
The raw PR fix prevents the OOM/hang, but it can still publish incomplete span regions after breaking out of line-height reconstruction. pr-plus-reviewer applies the expert review feedback using the same root-cause strategy as try-fix-2: prevent zero line-height cache population in FindDefaultLineHeight, then remove the partial-region break from RecalculateSpanPositions. No candidate had a passing regression-test result; all executable attempts were blocked/inconclusive by Windows device-test infrastructure/result parsing, so ranking is based on code correctness and available build/hang evidence rather than a pass/fail result.
Candidate ranking
| Rank | Candidate | Test result | Assessment |
|---|---|---|---|
| 1 | pr-plus-reviewer |
Best overall. Applies expert feedback to the PR by fixing the non-positive cached line height at source and preserving complete span-region geometry. Equivalent correctness profile to try-fix-2, but named as the reviewer-applied PR candidate. |
|
| 2 | try-fix-2 |
Strongest independent try-fix. Build succeeded, the Label category did not hang, and it fixes the root cause in FindDefaultLineHeight. Ranked just below pr-plus-reviewer only because pr-plus-reviewer adopts the same approach as the PR-reviewer-applied candidate. |
|
| 3 | try-fix-1 |
Better than raw PR because it substitutes a positive fallback and avoids immediate partial geometry, but it still tolerates a poisoned cached MeasuredLineHeight and patches the arrange loop instead of the source. |
|
| 4 | try-fix-3 |
Avoids partial Region.FromLines(...), but the conservative rectangle fallback can over-match hit-testing for multiple gesture spans. |
|
| 5 | try-fix-4 |
Avoids publishing partial geometry, but can leave stale/default regions and disable hit-testing if the zero cache is never repopulated. | |
| 6 | pr |
Prevents the infinite loop/OOM, but unresolved review finding remains: break can truncate line geometry and publish an incomplete span region. |
Regression-test rule
No candidate had a confirmed passing regression-test result. The raw PR gate was inconclusive because Windows device-test result XML was empty/invalid, and all STEP 5a try-fix candidates were blocked by the Windows device-test result parser after builds completed. None of the candidates are treated as failing, but none receives a pass advantage.
Why pr-plus-reviewer wins
The issue root cause is a zero MeasuredLineHeight cached while the TextBlock is hidden/collapsed. The raw PR breaks the downstream reconstruction loop when that zero appears, which avoids the unbounded loop but leaves downstream region assignment with partial data. The reviewer-applied candidate fixes the cache before RecalculateSpanPositions observes it, which makes the loop terminate normally and preserves wrapped span regions.
Recommended action
Adopt the pr-plus-reviewer implementation: move the guard/fallback to TextBlockExtensions.FindDefaultLineHeight, remove the lineHeight <= 0 break from FormattedStringExtensions.RecalculateSpanPositions, and keep the Windows no-hang regression test. If time permits, add a follow-up assertion/test for span-region or gesture hit-testing across wrapped formatted text, because the current test only proves the UI thread does not hang.
🧭 Next Steps — review latest findings
No alternative fix was selected for this run. Review the session findings and CI results before merging.
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…on (#36828) <!-- Please keep the note below for people who 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 whether this change resolves your issue. Thank you! This pull request addresses a critical bug where showing a `Label` with formatted text after it has been hidden could cause the UI thread to hang and eventually crash with an `OutOfMemoryException`. The fix introduces a guard against zero or negative line heights in the `RecalculateSpanPositions` method. Additionally, a new test is added to ensure this scenario is handled correctly. ### Description of Change: **Bug fix for line height calculation:** * Added a guard in `RecalculateSpanPositions` (in `FormattedStringExtensions.cs`) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when a `TextBlock` is measured while collapsed or hidden. **Testing improvements:** * Added a test (`FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden`) in `LabelTests.Windows.cs` to verify that showing a previously hidden label with formatted text does not hang or crash the UI. * Added necessary `using` directives for `Microsoft.Maui.Controls` and `Xunit` to support the new test. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #35527 ### Tested the behavior in the following platforms - [x] Windows - [ ] Android - [ ] iOS - [ ] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="1404" height="560" alt="BeforeFix35527" src="https://github.com/user-attachments/assets/5701a105-c57f-4f84-be87-2e1eacfa97d1" /> | <img width="1417" height="732" alt="AfterFix35527" src="https://github.com/user-attachments/assets/f85350ef-43bb-47a6-8273-eb3446b81c95" /> | <!-- <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
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 from this PR and let us know in a comment whether this change resolves your issue. Thank you!
This pull request addresses a critical bug where showing a
Labelwith formatted text after it has been hidden could cause the UI thread to hang and eventually crash with anOutOfMemoryException. The fix introduces a guard against zero or negative line heights in theRecalculateSpanPositionsmethod. Additionally, a new test is added to ensure this scenario is handled correctly.Description of Change:
Bug fix for line height calculation:
RecalculateSpanPositions(inFormattedStringExtensions.cs) to break out of the loop if a zero or negative line height is encountered, preventing infinite loops and memory issues when aTextBlockis measured while collapsed or hidden.Testing improvements:
FormattedTextDoesNotHangOrCrashWhenLabelIsShownAfterBeingSetWhileHidden) inLabelTests.Windows.csto verify that showing a previously hidden label with formatted text does not hang or crash the UI.usingdirectives forMicrosoft.Maui.ControlsandXunitto support the new test.Issues Fixed
Fixes #35527
Tested the behavior in the following platforms