Skip to content

[Android] Fix VerifyHybridWebViewWithShadow UI test regression on candidate branch#35013

Merged
kubaflo merged 1 commit into
dotnet:inflight/candidatefrom
praveenkumarkarunanithi:fix-31475-Reg
Apr 17, 2026
Merged

[Android] Fix VerifyHybridWebViewWithShadow UI test regression on candidate branch#35013
kubaflo merged 1 commit into
dotnet:inflight/candidatefrom
praveenkumarkarunanithi:fix-31475-Reg

Conversation

@praveenkumarkarunanithi

Copy link
Copy Markdown
Contributor

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 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 when clipping is disabled

Issues Fixed

Fixes regression introduced by #33207 :
VerifyHybridWebViewWithShadow on Candidate branch.

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 17, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review April 17, 2026 13:39
@kubaflo kubaflo merged commit 45828d8 into dotnet:inflight/candidate Apr 17, 2026
4 of 12 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR6 milestone Apr 17, 2026
@sheiksyedm sheiksyedm modified the milestones: .NET 10 SR6, .NET 10 SR7 Apr 18, 2026
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
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants