Repository navigation
[Windows] Keep the shadow host out of XAML bounds so Border captures stay clipped - #40353
Conversation
…stay clipped WrapperView hosts a view's DropShadow in a Rectangle whose only job is to carry the composition SpriteVisual. The Rectangle had a Transparent Fill, which gives it XAML content bounds. RenderTargetBitmap sizes captures from GetInnerBounds (content bounds plus transformed child bounds) and ignores composition clips, so a shadowed, scaled view inside a clipped Border made the capture larger than the Border and shifted its content. Since #40175 the shape mask is produced synchronously, so the host is sized before the capture and BorderTests.BorderClipsScaledContentWithShadow-style rows fail with transparent pixels at the Border centre. Leave the host without a Fill. A shape with no Fill/Stroke contributes no content bounds and is not hit-testable, while its hand-in visual (the shadow) still renders. This matches the same view without a shadow. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit b68eda2.
|
The validation conditions in the description are met on this PR's CI for head
Marking ready for review. |
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit b68eda2.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…stay clipped (#40353) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346, #40348, #40349, #40350). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure:** on the candidate, the Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)` fails in both packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected red). The rows without a shadow pass. #40349 did not change this result. **Cause:** - `WrapperView` hosts a view's `DropShadow` in a `Rectangle` (`_shadowHost`) whose only job is to carry the composition `SpriteVisual`. That Rectangle had `Fill = Transparent`. - A filled shape (even a transparent one) has XAML content bounds. `RenderTargetBitmap` sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips. - In this test the shadowed BoxView has `Scale = 3` inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100. - **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask before `UpdateShadowSize`. Before #40175 the mask came from an async `RenderTargetBitmap`, so the host was still 0×0 when the test captured. Since #40175 (and #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs. - The Transparent fill dates back to #570 and has no stated purpose. **Fix:** create the shadow host without a `Fill`. - A WinUI shape with no Fill and no Stroke has empty content bounds (`CShape::GenerateContentBounds`), so it no longer enlarges captures. - Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds. - The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an `InputTransparent` layout with a shadow, because Windows doesn't apply `InputTransparent` to the wrapper for layouts. No tests, baselines, tolerances or waits are changed. **Validation:** - Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with `-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in `WrapperView.cs`. - Windows runtime validation runs on this PR's device-test (`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays a draft until: - the Border shadow row passes; - the other Border rows stay green; - the Windows shadow and BoxView UI tests (for example `ShadowFeatureTests` and `BoxViewFeatureTests`) stay green. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row failure on the SR2 candidate (#40116). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stay clipped (#40353) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346, #40348, #40349, #40350). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure:** on the candidate, the Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)` fails in both packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected red). The rows without a shadow pass. #40349 did not change this result. **Cause:** - `WrapperView` hosts a view's `DropShadow` in a `Rectangle` (`_shadowHost`) whose only job is to carry the composition `SpriteVisual`. That Rectangle had `Fill = Transparent`. - A filled shape (even a transparent one) has XAML content bounds. `RenderTargetBitmap` sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips. - In this test the shadowed BoxView has `Scale = 3` inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100. - **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask before `UpdateShadowSize`. Before #40175 the mask came from an async `RenderTargetBitmap`, so the host was still 0×0 when the test captured. Since #40175 (and #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs. - The Transparent fill dates back to #570 and has no stated purpose. **Fix:** create the shadow host without a `Fill`. - A WinUI shape with no Fill and no Stroke has empty content bounds (`CShape::GenerateContentBounds`), so it no longer enlarges captures. - Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds. - The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an `InputTransparent` layout with a shadow, because Windows doesn't apply `InputTransparent` to the wrapper for layouts. No tests, baselines, tolerances or waits are changed. **Validation:** - Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with `-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in `WrapperView.cs`. - Windows runtime validation runs on this PR's device-test (`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays a draft until: - the Border shadow row passes; - the other Border rows stay green; - the Windows shadow and BoxView UI tests (for example `ShadowFeatureTests` and `BoxViewFeatureTests`) stay green. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row failure on the SR2 candidate (#40116). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stay clipped (#40353) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346, #40348, #40349, #40350). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure:** on the candidate, the Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)` fails in both packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected red). The rows without a shadow pass. #40349 did not change this result. **Cause:** - `WrapperView` hosts a view's `DropShadow` in a `Rectangle` (`_shadowHost`) whose only job is to carry the composition `SpriteVisual`. That Rectangle had `Fill = Transparent`. - A filled shape (even a transparent one) has XAML content bounds. `RenderTargetBitmap` sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips. - In this test the shadowed BoxView has `Scale = 3` inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100. - **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask before `UpdateShadowSize`. Before #40175 the mask came from an async `RenderTargetBitmap`, so the host was still 0×0 when the test captured. Since #40175 (and #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs. - The Transparent fill dates back to #570 and has no stated purpose. **Fix:** create the shadow host without a `Fill`. - A WinUI shape with no Fill and no Stroke has empty content bounds (`CShape::GenerateContentBounds`), so it no longer enlarges captures. - Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds. - The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an `InputTransparent` layout with a shadow, because Windows doesn't apply `InputTransparent` to the wrapper for layouts. No tests, baselines, tolerances or waits are changed. **Validation:** - Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with `-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in `WrapperView.cs`. - Windows runtime validation runs on this PR's device-test (`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays a draft until: - the Border shadow row passes; - the other Border rows stay green; - the Windows shadow and BoxView UI tests (for example `ShadowFeatureTests` and `BoxViewFeatureTests`) stay green. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row failure on the SR2 candidate (#40116). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stay clipped (#40353) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346, #40348, #40349, #40350). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure:** on the candidate, the Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)` fails in both packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected red). The rows without a shadow pass. #40349 did not change this result. **Cause:** - `WrapperView` hosts a view's `DropShadow` in a `Rectangle` (`_shadowHost`) whose only job is to carry the composition `SpriteVisual`. That Rectangle had `Fill = Transparent`. - A filled shape (even a transparent one) has XAML content bounds. `RenderTargetBitmap` sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips. - In this test the shadowed BoxView has `Scale = 3` inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100. - **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask before `UpdateShadowSize`. Before #40175 the mask came from an async `RenderTargetBitmap`, so the host was still 0×0 when the test captured. Since #40175 (and #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs. - The Transparent fill dates back to #570 and has no stated purpose. **Fix:** create the shadow host without a `Fill`. - A WinUI shape with no Fill and no Stroke has empty content bounds (`CShape::GenerateContentBounds`), so it no longer enlarges captures. - Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds. - The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an `InputTransparent` layout with a shadow, because Windows doesn't apply `InputTransparent` to the wrapper for layouts. No tests, baselines, tolerances or waits are changed. **Validation:** - Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with `-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in `WrapperView.cs`. - Windows runtime validation runs on this PR's device-test (`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays a draft until: - the Border shadow row passes; - the other Border rows stay green; - the Windows shadow and BoxView UI tests (for example `ShadowFeatureTests` and `BoxViewFeatureTests`) stay green. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row failure on the SR2 candidate (#40116). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stay clipped (#40353) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346, #40348, #40349, #40350). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure:** on the candidate, the Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)` fails in both packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected red). The rows without a shadow pass. #40349 did not change this result. **Cause:** - `WrapperView` hosts a view's `DropShadow` in a `Rectangle` (`_shadowHost`) whose only job is to carry the composition `SpriteVisual`. That Rectangle had `Fill = Transparent`. - A filled shape (even a transparent one) has XAML content bounds. `RenderTargetBitmap` sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips. - In this test the shadowed BoxView has `Scale = 3` inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100. - **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask before `UpdateShadowSize`. Before #40175 the mask came from an async `RenderTargetBitmap`, so the host was still 0×0 when the test captured. Since #40175 (and #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs. - The Transparent fill dates back to #570 and has no stated purpose. **Fix:** create the shadow host without a `Fill`. - A WinUI shape with no Fill and no Stroke has empty content bounds (`CShape::GenerateContentBounds`), so it no longer enlarges captures. - Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds. - The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an `InputTransparent` layout with a shadow, because Windows doesn't apply `InputTransparent` to the wrapper for layouts. No tests, baselines, tolerances or waits are changed. **Validation:** - Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with `-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in `WrapperView.cs`. - Windows runtime validation runs on this PR's device-test (`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays a draft until: - the Border shadow row passes; - the other Border rows stay green; - the Windows shadow and BoxView UI tests (for example `ShadowFeatureTests` and `BoxViewFeatureTests`) stay green. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row failure on the SR2 candidate (#40116). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stay clipped (#40353) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346, #40348, #40349, #40350). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure:** on the candidate, the Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)` fails in both packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected red). The rows without a shadow pass. #40349 did not change this result. **Cause:** - `WrapperView` hosts a view's `DropShadow` in a `Rectangle` (`_shadowHost`) whose only job is to carry the composition `SpriteVisual`. That Rectangle had `Fill = Transparent`. - A filled shape (even a transparent one) has XAML content bounds. `RenderTargetBitmap` sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips. - In this test the shadowed BoxView has `Scale = 3` inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100. - **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask before `UpdateShadowSize`. Before #40175 the mask came from an async `RenderTargetBitmap`, so the host was still 0×0 when the test captured. Since #40175 (and #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs. - The Transparent fill dates back to #570 and has no stated purpose. **Fix:** create the shadow host without a `Fill`. - A WinUI shape with no Fill and no Stroke has empty content bounds (`CShape::GenerateContentBounds`), so it no longer enlarges captures. - Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds. - The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an `InputTransparent` layout with a shadow, because Windows doesn't apply `InputTransparent` to the wrapper for layouts. No tests, baselines, tolerances or waits are changed. **Validation:** - Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with `-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in `WrapperView.cs`. - Windows runtime validation runs on this PR's device-test (`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays a draft until: - the Border shadow row passes; - the other Border rows stay green; - the Windows shadow and BoxView UI tests (for example `ShadowFeatureTests` and `BoxViewFeatureTests`) stay green. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row failure on the SR2 candidate (#40116). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stay clipped (dotnet#40353) <!-- 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! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a candidate-acceptance fix for SR2 candidate PR dotnet#40116, so it targets `candidate/11.0.1xx-sr2` like the other candidate fixes (dotnet#40346, dotnet#40348, dotnet#40349, dotnet#40350). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure:** on the candidate, the Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)` fails in both packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected red). The rows without a shadow pass. dotnet#40349 did not change this result. **Cause:** - `WrapperView` hosts a view's `DropShadow` in a `Rectangle` (`_shadowHost`) whose only job is to carry the composition `SpriteVisual`. That Rectangle had `Fill = Transparent`. - A filled shape (even a transparent one) has XAML content bounds. `RenderTargetBitmap` sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips. - In this test the shadowed BoxView has `Scale = 3` inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100. - **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask before `UpdateShadowSize`. Before dotnet#40175 the mask came from an async `RenderTargetBitmap`, so the host was still 0×0 when the test captured. Since dotnet#40175 (and dotnet#40349) the shape mask is produced synchronously, so the host is already sized when the capture runs. - The Transparent fill dates back to dotnet#570 and has no stated purpose. **Fix:** create the shadow host without a `Fill`. - A WinUI shape with no Fill and no Stroke has empty content bounds (`CShape::GenerateContentBounds`), so it no longer enlarges captures. - Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds. - The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an `InputTransparent` layout with a shadow, because Windows doesn't apply `InputTransparent` to the wrapper for layouts. No tests, baselines, tolerances or waits are changed. **Validation:** - Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with `-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in `WrapperView.cs`. - Windows runtime validation runs on this PR's device-test (`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays a draft until: - the Border shadow row passes; - the other Border rows stay green; - the Windows shadow and BoxView UI tests (for example `ShadowFeatureTests` and `BoxViewFeatureTests`) stay green. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row failure on the SR2 candidate (dotnet#40116). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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 if this change resolves your issue. Thank you!
Target Branch
mainnet11, for reviewThis is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets
candidate/11.0.1xx-sr2like the other candidate fixes (#40346, #40348, #40349, #40350).For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
Failure: on the candidate, the Windows device test
BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true)fails in both packaged and unpackaged runs with(50,50) was (0,0,0,0)(expected red). The rows without a shadow pass. #40349 did not change this result.Cause:
WrapperViewhosts a view'sDropShadowin aRectangle(_shadowHost) whose only job is to carry the compositionSpriteVisual. That Rectangle hadFill = Transparent.RenderTargetBitmapsizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips.Scale = 3inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100.UpdateShadowAsyncawaits the alpha mask beforeUpdateShadowSize. Before [Windows] Fix Boxview shadow is not aligned with box view shape #40175 the mask came from an asyncRenderTargetBitmap, so the host was still 0×0 when the test captured. Since [Windows] Fix Boxview shadow is not aligned with box view shape #40175 (and [Windows] Render shape shadow masks offscreen so captures keep shadowed shapes #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs.Fix: create the shadow host without a
Fill.CShape::GenerateContentBounds), so it no longer enlarges captures.InputTransparentlayout with a shadow, because Windows doesn't applyInputTransparentto the wrapper for layouts.No tests, baselines, tolerances or waits are changed.
Validation:
src/Core/src/Core.csprojwith-p:TargetFrameworks=net11.0-windows10.0.19041.0produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are inWrapperView.cs.maui-pr-devicetests) and UI-test (maui-pr-uitests) CI. The PR stays a draft until:ShadowFeatureTestsandBoxViewFeatureTests) stay green.Issues Fixed
Fixes the Windows
BorderClipsTransformedContentToItsShapeshadow-row failure on the SR2 candidate (#40116).