Repository navigation
[Windows] Render shape shadow masks offscreen so captures keep shadowed shapes - #40349
Merged
Merged
Conversation
…ed shapes #40175 made BoxView/shape shadows use a live CompositionVisualSurface of the element as the DropShadow mask. With that surface attached, the shape's own content is missing from RenderTargetBitmap captures, so the Windows device test BorderClipsTransformedContentToItsShape(hasShadow: true) reads a transparent pixel where the red BoxView should be. Render the ShapeDrawable into an offscreen Win2D CanvasRenderTarget instead, mirroring W2DGraphicsView's draw (logical-size scale and RTL flip), and use it as a static mask. Refresh the mask when the shape is replaced or invalidated so the shadow keeps following shape changes, as #40175 intended. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
temporarily deployed
to
copilot-pat-pool
November 17, 2026 22:27 — with
GitHub Actions
Inactive
This comment has been minimized.
This comment has been minimized.
kubaflo
temporarily deployed
to
copilot-pat-pool
November 17, 2026 22:27 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 17, 2026 22:28 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 17, 2026 22:30 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 17, 2026 22:32 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 17, 2026 22:33 — with
GitHub Actions
Inactive
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
/rebase |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
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. |
1 task done
Open
3 tasks
1 task
kubaflo
added a commit
that referenced
this pull request
Nov 18, 2026
…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>
kubaflo
added a commit
that referenced
this pull request
Nov 18, 2026
…ed shapes (#40349) <!-- 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 repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. 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 **Regression.** The Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)` fails deterministically on net11 and on the candidate with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`. - The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the next build, 1680671 (`ea39223fd0`), failed. - #40175's only product change is in `ShadowExtensions.cs`. For a `W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask with a live `CompositionVisualSurface` whose `SourceVisual` is the element's own visual. - With that surface attached, the shape's content is missing from `RenderTargetBitmap` captures. That covers the device test's `RawBitmap` capture and `CaptureAsync` on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so `RenderTargetBitmap` itself does capture Win2D content. **Fix** (this keeps #40175's goal from #31821, a shadow that follows the shape): - `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable` into an offscreen Win2D `CanvasRenderTarget` and uses the result as a static `DropShadow` mask, the same kind of mask other elements get. It mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the `CanvasControl` has drawn yet. - Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and `ShapesExtensions.InvalidateShape` now call a new internal `WrapperView.InvalidateShadow()`. It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through `UpdateShadowAsync`. There are no public API changes, no test changes and no baseline or tolerance changes. **Validation** - Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at #40175, as described above. - Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`. - **Passed** for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`, `NavigationRootManager.cs`), which macOS can't run. - Negative controls prove the changed files are compiled. Injecting `int x = "x";` produced CS0029 in `ShadowExtensions.cs`, `ShapesExtensions.cs` and `WrapperView.cs`. The controls were then reverted. - `dotnet format whitespace --folder --verify-no-changes --include <3 changed files>`: **passed**. - **Not run locally:** I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: `maui-pr-devicetests` Windows Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests` Windows BoxView/Shadow snapshots. Those snapshots include #40175's `BoxView_*AndShadow` baselines, which have not been changed here. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow: true)` regression found while validating #40116. It keeps the shape-following shadow fix for #31821. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Nov 18, 2026
…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>
kubaflo
added a commit
that referenced
this pull request
Nov 18, 2026
…ed shapes (#40349) <!-- 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 repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. 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 **Regression.** The Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)` fails deterministically on net11 and on the candidate with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`. - The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the next build, 1680671 (`ea39223fd0`), failed. - #40175's only product change is in `ShadowExtensions.cs`. For a `W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask with a live `CompositionVisualSurface` whose `SourceVisual` is the element's own visual. - With that surface attached, the shape's content is missing from `RenderTargetBitmap` captures. That covers the device test's `RawBitmap` capture and `CaptureAsync` on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so `RenderTargetBitmap` itself does capture Win2D content. **Fix** (this keeps #40175's goal from #31821, a shadow that follows the shape): - `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable` into an offscreen Win2D `CanvasRenderTarget` and uses the result as a static `DropShadow` mask, the same kind of mask other elements get. It mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the `CanvasControl` has drawn yet. - Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and `ShapesExtensions.InvalidateShape` now call a new internal `WrapperView.InvalidateShadow()`. It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through `UpdateShadowAsync`. There are no public API changes, no test changes and no baseline or tolerance changes. **Validation** - Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at #40175, as described above. - Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`. - **Passed** for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`, `NavigationRootManager.cs`), which macOS can't run. - Negative controls prove the changed files are compiled. Injecting `int x = "x";` produced CS0029 in `ShadowExtensions.cs`, `ShapesExtensions.cs` and `WrapperView.cs`. The controls were then reverted. - `dotnet format whitespace --folder --verify-no-changes --include <3 changed files>`: **passed**. - **Not run locally:** I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: `maui-pr-devicetests` Windows Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests` Windows BoxView/Shadow snapshots. Those snapshots include #40175's `BoxView_*AndShadow` baselines, which have not been changed here. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow: true)` regression found while validating #40116. It keeps the shape-following shadow fix for #31821. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Nov 18, 2026
…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>
kubaflo
added a commit
that referenced
this pull request
Nov 18, 2026
…ed shapes (#40349) <!-- 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 repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. 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 **Regression.** The Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)` fails deterministically on net11 and on the candidate with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`. - The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the next build, 1680671 (`ea39223fd0`), failed. - #40175's only product change is in `ShadowExtensions.cs`. For a `W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask with a live `CompositionVisualSurface` whose `SourceVisual` is the element's own visual. - With that surface attached, the shape's content is missing from `RenderTargetBitmap` captures. That covers the device test's `RawBitmap` capture and `CaptureAsync` on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so `RenderTargetBitmap` itself does capture Win2D content. **Fix** (this keeps #40175's goal from #31821, a shadow that follows the shape): - `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable` into an offscreen Win2D `CanvasRenderTarget` and uses the result as a static `DropShadow` mask, the same kind of mask other elements get. It mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the `CanvasControl` has drawn yet. - Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and `ShapesExtensions.InvalidateShape` now call a new internal `WrapperView.InvalidateShadow()`. It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through `UpdateShadowAsync`. There are no public API changes, no test changes and no baseline or tolerance changes. **Validation** - Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at #40175, as described above. - Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`. - **Passed** for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`, `NavigationRootManager.cs`), which macOS can't run. - Negative controls prove the changed files are compiled. Injecting `int x = "x";` produced CS0029 in `ShadowExtensions.cs`, `ShapesExtensions.cs` and `WrapperView.cs`. The controls were then reverted. - `dotnet format whitespace --folder --verify-no-changes --include <3 changed files>`: **passed**. - **Not run locally:** I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: `maui-pr-devicetests` Windows Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests` Windows BoxView/Shadow snapshots. Those snapshots include #40175's `BoxView_*AndShadow` baselines, which have not been changed here. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow: true)` regression found while validating #40116. It keeps the shape-following shadow fix for #31821. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Nov 18, 2026
…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>
kubaflo
added a commit
that referenced
this pull request
Nov 19, 2026
…ed shapes (#40349) <!-- 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 repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. 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 **Regression.** The Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)` fails deterministically on net11 and on the candidate with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`. - The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the next build, 1680671 (`ea39223fd0`), failed. - #40175's only product change is in `ShadowExtensions.cs`. For a `W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask with a live `CompositionVisualSurface` whose `SourceVisual` is the element's own visual. - With that surface attached, the shape's content is missing from `RenderTargetBitmap` captures. That covers the device test's `RawBitmap` capture and `CaptureAsync` on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so `RenderTargetBitmap` itself does capture Win2D content. **Fix** (this keeps #40175's goal from #31821, a shadow that follows the shape): - `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable` into an offscreen Win2D `CanvasRenderTarget` and uses the result as a static `DropShadow` mask, the same kind of mask other elements get. It mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the `CanvasControl` has drawn yet. - Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and `ShapesExtensions.InvalidateShape` now call a new internal `WrapperView.InvalidateShadow()`. It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through `UpdateShadowAsync`. There are no public API changes, no test changes and no baseline or tolerance changes. **Validation** - Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at #40175, as described above. - Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`. - **Passed** for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`, `NavigationRootManager.cs`), which macOS can't run. - Negative controls prove the changed files are compiled. Injecting `int x = "x";` produced CS0029 in `ShadowExtensions.cs`, `ShapesExtensions.cs` and `WrapperView.cs`. The controls were then reverted. - `dotnet format whitespace --folder --verify-no-changes --include <3 changed files>`: **passed**. - **Not run locally:** I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: `maui-pr-devicetests` Windows Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests` Windows BoxView/Shadow snapshots. Those snapshots include #40175's `BoxView_*AndShadow` baselines, which have not been changed here. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow: true)` regression found while validating #40116. It keeps the shape-following shadow fix for #31821. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Nov 19, 2026
…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>
kubaflo
added a commit
that referenced
this pull request
Nov 22, 2026
…ed shapes (#40349) <!-- 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 repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. 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 **Regression.** The Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)` fails deterministically on net11 and on the candidate with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`. - The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the next build, 1680671 (`ea39223fd0`), failed. - #40175's only product change is in `ShadowExtensions.cs`. For a `W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask with a live `CompositionVisualSurface` whose `SourceVisual` is the element's own visual. - With that surface attached, the shape's content is missing from `RenderTargetBitmap` captures. That covers the device test's `RawBitmap` capture and `CaptureAsync` on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so `RenderTargetBitmap` itself does capture Win2D content. **Fix** (this keeps #40175's goal from #31821, a shadow that follows the shape): - `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable` into an offscreen Win2D `CanvasRenderTarget` and uses the result as a static `DropShadow` mask, the same kind of mask other elements get. It mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the `CanvasControl` has drawn yet. - Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and `ShapesExtensions.InvalidateShape` now call a new internal `WrapperView.InvalidateShadow()`. It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through `UpdateShadowAsync`. There are no public API changes, no test changes and no baseline or tolerance changes. **Validation** - Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at #40175, as described above. - Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`. - **Passed** for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`, `NavigationRootManager.cs`), which macOS can't run. - Negative controls prove the changed files are compiled. Injecting `int x = "x";` produced CS0029 in `ShadowExtensions.cs`, `ShapesExtensions.cs` and `WrapperView.cs`. The controls were then reverted. - `dotnet format whitespace --folder --verify-no-changes --include <3 changed files>`: **passed**. - **Not run locally:** I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: `maui-pr-devicetests` Windows Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests` Windows BoxView/Shadow snapshots. Those snapshots include #40175's `BoxView_*AndShadow` baselines, which have not been changed here. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow: true)` regression found while validating #40116. It keeps the shape-following shadow fix for #31821. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Nov 22, 2026
…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>
kubaflo
added a commit
that referenced
this pull request
Nov 23, 2026
…ed shapes (#40349) <!-- 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 repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. 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 **Regression.** The Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)` fails deterministically on net11 and on the candidate with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`. - The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the next build, 1680671 (`ea39223fd0`), failed. - #40175's only product change is in `ShadowExtensions.cs`. For a `W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask with a live `CompositionVisualSurface` whose `SourceVisual` is the element's own visual. - With that surface attached, the shape's content is missing from `RenderTargetBitmap` captures. That covers the device test's `RawBitmap` capture and `CaptureAsync` on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so `RenderTargetBitmap` itself does capture Win2D content. **Fix** (this keeps #40175's goal from #31821, a shadow that follows the shape): - `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable` into an offscreen Win2D `CanvasRenderTarget` and uses the result as a static `DropShadow` mask, the same kind of mask other elements get. It mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the `CanvasControl` has drawn yet. - Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and `ShapesExtensions.InvalidateShape` now call a new internal `WrapperView.InvalidateShadow()`. It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through `UpdateShadowAsync`. There are no public API changes, no test changes and no baseline or tolerance changes. **Validation** - Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at #40175, as described above. - Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`. - **Passed** for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`, `NavigationRootManager.cs`), which macOS can't run. - Negative controls prove the changed files are compiled. Injecting `int x = "x";` produced CS0029 in `ShadowExtensions.cs`, `ShapesExtensions.cs` and `WrapperView.cs`. The controls were then reverted. - `dotnet format whitespace --folder --verify-no-changes --include <3 changed files>`: **passed**. - **Not run locally:** I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: `maui-pr-devicetests` Windows Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests` Windows BoxView/Shadow snapshots. Those snapshots include #40175's `BoxView_*AndShadow` baselines, which have not been changed here. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow: true)` regression found while validating #40116. It keeps the shape-following shadow fix for #31821. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Nov 23, 2026
…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>
KarthikRajaKalaimani
pushed a commit
to KarthikRajaKalaimani/maui
that referenced
this pull request
Nov 26, 2026
…ed shapes (dotnet#40349) <!-- 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 repair for the SR2 candidate (dotnet#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. 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 **Regression.** The Windows device test `BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)` fails deterministically on net11 and on the candidate with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`. - The onset is dotnet#40175 (`ea39223fd0` on net11, `219a32fbcc` on the candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the next build, 1680671 (`ea39223fd0`), failed. - dotnet#40175's only product change is in `ShadowExtensions.cs`. For a `W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask with a live `CompositionVisualSurface` whose `SourceVisual` is the element's own visual. - With that surface attached, the shape's content is missing from `RenderTargetBitmap` captures. That covers the device test's `RawBitmap` capture and `CaptureAsync` on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so `RenderTargetBitmap` itself does capture Win2D content. **Fix** (this keeps dotnet#40175's goal from dotnet#31821, a shadow that follows the shape): - `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable` into an offscreen Win2D `CanvasRenderTarget` and uses the result as a static `DropShadow` mask, the same kind of mask other elements get. It mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the `CanvasControl` has drawn yet. - Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and `ShapesExtensions.InvalidateShape` now call a new internal `WrapperView.InvalidateShadow()`. It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through `UpdateShadowAsync`. There are no public API changes, no test changes and no baseline or tolerance changes. **Validation** - Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at dotnet#40175, as described above. - Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`. - **Passed** for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`, `NavigationRootManager.cs`), which macOS can't run. - Negative controls prove the changed files are compiled. Injecting `int x = "x";` produced CS0029 in `ShadowExtensions.cs`, `ShapesExtensions.cs` and `WrapperView.cs`. The controls were then reverted. - `dotnet format whitespace --folder --verify-no-changes --include <3 changed files>`: **passed**. - **Not run locally:** I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: `maui-pr-devicetests` Windows Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests` Windows BoxView/Shadow snapshots. Those snapshots include dotnet#40175's `BoxView_*AndShadow` baselines, which have not been changed here. ### Issues Fixed Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow: true)` regression found while validating dotnet#40116. It keeps the shape-following shadow fix for dotnet#31821. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
KarthikRajaKalaimani
pushed a commit
to KarthikRajaKalaimani/maui
that referenced
this pull request
Nov 26, 2026
…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>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 repair for the SR2 candidate (#40116), so it targets
candidate/11.0.1xx-sr2as assigned.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
Regression. The Windows device test
BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true)fails deterministically on net11 and on the candidate withpixel (50,50) expected red, was (0,0,0,0). It passes onmain.ea39223fd0on net11,219a32fbccon the candidate). net11 device build 1680463 (b2d31412a9) passed, and the next build, 1680671 (ea39223fd0), failed.ShadowExtensions.cs. For aW2DGraphicsViewwith aShapeDrawable, it replaced the static mask with a liveCompositionVisualSurfacewhoseSourceVisualis the element's own visual.RenderTargetBitmapcaptures. That covers the device test'sRawBitmapcapture andCaptureAsyncon Windows. The hasShadow:false rows of the same theory still capture the Win2D content, soRenderTargetBitmapitself does capture Win2D content.Fix (this keeps #40175's goal from #31821, a shadow that follows the shape):
ShadowExtensions.GetShapeAlphaMaskdraws the view'sShapeDrawableinto an offscreen Win2DCanvasRenderTargetand uses the result as a staticDropShadowmask, the same kind of mask other elements get. It mirrorsW2DGraphicsView.OnDraw: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether theCanvasControlhas drawn yet.ShapesExtensions.UpdateShapeandShapesExtensions.InvalidateShapenow call a new internalWrapperView.InvalidateShadow(). It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask throughUpdateShadowAsync.There are no public API changes, no test changes and no baseline or tolerance changes.
Validation
dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false.MauiToolbar.xaml.cs,RootNavigationView.cs,NavigationRootManager.cs), which macOS can't run.int x = "x";produced CS0029 inShadowExtensions.cs,ShapesExtensions.csandWrapperView.cs. The controls were then reverted.dotnet format whitespace --folder --verify-no-changes --include <3 changed files>: passed.maui-pr-devicetestsWindows Border (BorderClipsTransformedContentToItsShape) andmaui-pr-uitestsWindows BoxView/Shadow snapshots. Those snapshots include [Windows] Fix Boxview shadow is not aligned with box view shape #40175'sBoxView_*AndShadowbaselines, which have not been changed here.Issues Fixed
Fixes the Windows
BorderClipsTransformedContentToItsShape(hasShadow: true)regression found while validating #40116. It keeps the shape-following shadow fix for #31821.