[Android] Fix VerifyHybridWebViewWithShadow UI test regression on candidate branch#35013
Merged
kubaflo merged 1 commit intoApr 17, 2026
Merged
Conversation
kubaflo
approved these changes
Apr 17, 2026
This was referenced Apr 18, 2026
Merged
4 tasks
kubaflo
pushed a commit
that referenced
this pull request
Apr 21, 2026
…n on candidate branch (#35057) <!-- 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! ### Root Cause The previous regression fix (PR #35013) set `ClipBounds = null` unconditionally in `OnSizeChanged` to resolve shadow clipping. While effective for shadows, this reintroduced the original full-screen flash issue (#31475) on slower devices. The underlying issue is that `ClipBounds = null` removes GPU-level rendering constraints. On slower devices, the hardware-accelerated WebView compositor renders a frame at full-screen size before Android layout bounds are enforced. Debug analysis showed that when Shadow/Border/Clip is applied, MAUI wraps the WebView inside a `WrapperView`. In this scenario, the wrapper constrains rendering, making `ClipBounds = null` safe. Without decorations, the WebView is hosted directly under `LayoutViewGroup` (with `ClipChildren = false`), requiring explicit bounds to prevent the flash. ### Description of Change Introduced a `UpdateClipBounds` method to dynamically determine the correct clipping strategy based on the parent: * **Parent is WrapperView (decorations applied):** Sets `ClipBounds = null` to allow shadow and visual overflow * **Parent is not WrapperView (no decorations):** Sets exact bounds to prevent full-screen flash on slower devices * **Zero size:** Applies empty bounds to block rendering when the view is collapsed Additionally, added an `OnAttachedToWindow` override to re-evaluate `ClipBounds` during runtime re-parenting (e.g., when shadow is toggled). This is required because re-parenting does not trigger `OnSizeChanged`. This approach aligns with existing MAUI patterns (e.g., `ContentViewGroup` handling parent checks in similar lifecycle hooks). ### Issues Fixed Fixes regression introduced by #35013 : `WebViewBackgroundColorShouldBeApplied` on Candidate branch. Tested the behaviour in the following platforms - [x] Android - [ ] Windows - [ ] iOS - [ ] Mac
Ahamed-Ali
pushed a commit
that referenced
this pull request
Apr 22, 2026
…ndidate branch (#35013) <!-- 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! ### Root Cause Applying `ClipBounds = Rect(0, 0, width, height)` constrained the WebView strictly to its layout bounds, preventing shadows (rendered by the parent `WrapperView`) from drawing outside the view. This clipped the shadow and caused UI test failures due to visual mismatch with baseline snapshots. ### Description of Change Updated logic to set `ClipBounds = null` once the view has a valid size, restoring default Android behavior where layout bounds (not `ClipBounds`) control rendering. - Constructor still applies an empty clip to prevent pre-layout full-screen flash - Zero-size scenarios reapply the empty clip to maintain correctness - Aligns with existing handling in `LayoutViewGroup` [Ref](https://github.com/praveenkumarkarunanithi/maui/blob/main/src/Core/src/Platform/Android/LayoutViewGroup.cs#L161) when clipping is disabled ### Issues Fixed Fixes regression introduced by #33207 : `VerifyHybridWebViewWithShadow` on Candidate branch. Tested the behaviour in the following platforms - [x] Android - [ ] Windows - [ ] iOS - [ ] Mac
Ahamed-Ali
pushed a commit
that referenced
this pull request
Apr 22, 2026
…n on candidate branch (#35057) <!-- 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! ### Root Cause The previous regression fix (PR #35013) set `ClipBounds = null` unconditionally in `OnSizeChanged` to resolve shadow clipping. While effective for shadows, this reintroduced the original full-screen flash issue (#31475) on slower devices. The underlying issue is that `ClipBounds = null` removes GPU-level rendering constraints. On slower devices, the hardware-accelerated WebView compositor renders a frame at full-screen size before Android layout bounds are enforced. Debug analysis showed that when Shadow/Border/Clip is applied, MAUI wraps the WebView inside a `WrapperView`. In this scenario, the wrapper constrains rendering, making `ClipBounds = null` safe. Without decorations, the WebView is hosted directly under `LayoutViewGroup` (with `ClipChildren = false`), requiring explicit bounds to prevent the flash. ### Description of Change Introduced a `UpdateClipBounds` method to dynamically determine the correct clipping strategy based on the parent: * **Parent is WrapperView (decorations applied):** Sets `ClipBounds = null` to allow shadow and visual overflow * **Parent is not WrapperView (no decorations):** Sets exact bounds to prevent full-screen flash on slower devices * **Zero size:** Applies empty bounds to block rendering when the view is collapsed Additionally, added an `OnAttachedToWindow` override to re-evaluate `ClipBounds` during runtime re-parenting (e.g., when shadow is toggled). This is required because re-parenting does not trigger `OnSizeChanged`. This approach aligns with existing MAUI patterns (e.g., `ContentViewGroup` handling parent checks in similar lifecycle hooks). ### Issues Fixed Fixes regression introduced by #35013 : `WebViewBackgroundColorShouldBeApplied` on Candidate branch. Tested the behaviour in the following platforms - [x] Android - [ ] Windows - [ ] iOS - [ ] Mac
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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!
Root Cause
Applying
ClipBounds = Rect(0, 0, width, height)constrained the WebView strictly to its layout bounds, preventing shadows (rendered by the parentWrapperView) from drawing outside the view. This clipped the shadow and caused UI test failures due to visual mismatch with baseline snapshots.Description of Change
Updated logic to set
ClipBounds = nullonce the view has a valid size, restoring default Android behavior where layout bounds (notClipBounds) control rendering.LayoutViewGroupRef when clipping is disabledIssues Fixed
Fixes regression introduced by #33207 :
VerifyHybridWebViewWithShadowon Candidate branch.Tested the behaviour in the following platforms