Skip to content

[Testing] Fix for flaky device test BlazorWebViewUsesStartPath on Windows #29966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

anandhan-rajagopal
Copy link
Contributor

Description

This PR addresses the flakiness observed in Blazor device tests, particularly the recurring error:

Waited 30000ms but couldn't get CoreWebView2 to be available

Build Link: https://dev.azure.com/xamarin/public/_build/results?buildId=143779&view=ms.vss-test-web.build-test-results-tab&runId=4309282&resultId=100000&paneView=debug

Root Cause

The failure is due to the WebView2 runtime not being available or failing to initialize in certain test environments. This is not related to the test logic but rather a system setup issue—specifically, the runtime dependency on a Windows GUI environment with WebView2 support.

Solution Description

Solution added WaitForWebViewReady method in WebViewHelpers.Windows.cs to ensure that the WebView2 runtime is properly installed and initialized before proceeding. The key change adds a check for the WebView2 runtime and initializes it if necessary.

@Copilot Copilot AI review requested due to automatic review settings June 12, 2025 14:34
@anandhan-rajagopal anandhan-rajagopal requested a review from a team as a code owner June 12, 2025 14:34
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 12, 2025
Copy link
Contributor

Hey there @@anandhan-rajagopal! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 12, 2025
Copilot

This comment was marked as outdated.

@anandhan-rajagopal anandhan-rajagopal added the area-testing Unit tests, device tests label Jun 12, 2025
@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

{
throw new InvalidOperationException("WebView2 runtime is not installed.");
}
await wv2.EnsureCoreWebView2Async();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this called by the handler already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattleibow Yes, it was invoked in the handler already. However, the test failed in CI with the error 'Waited 30000ms but couldn't get CoreWebView2 to be available'. To address this, the call was added again to explicitly ensure proper initialization before the test begins, along with appropriate exception handling.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes flaky device tests for BlazorWebView on Windows by ensuring the WebView2 runtime is available and initialized before proceeding with the tests.

  • Adds a check for the WebView2 runtime availability using CoreWebView2Environment.GetAvailableBrowserVersionString.
  • Calls EnsureCoreWebView2Async when the CoreWebView2 instance is not yet available.

@PureWeen PureWeen changed the base branch from main to inflight/current June 24, 2025 17:19
@PureWeen PureWeen merged commit f4e33ab into dotnet:inflight/current Jun 24, 2025
131 of 132 checks passed
PureWeen pushed a commit that referenced this pull request Jun 25, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jun 26, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
PureWeen pushed a commit that referenced this pull request Jun 27, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
PureWeen pushed a commit that referenced this pull request Jun 28, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jun 29, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jun 29, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jul 1, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jul 2, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jul 2, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jul 8, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jul 8, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
github-actions bot pushed a commit that referenced this pull request Jul 9, 2025
…dows (#29966)

* Update WebViewHelpers.Windows.cs

* Update WebViewHelpers.Windows.cs

* Update src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-testing Unit tests, device tests community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants