Skip to content

[Windows] Remove 2nd WebView used to add base tag when using HtmlWebViewSource#21892

Merged
PureWeen merged 3 commits intomainfrom
foda/webview2crash
Apr 23, 2024
Merged

[Windows] Remove 2nd WebView used to add base tag when using HtmlWebViewSource#21892
PureWeen merged 3 commits intomainfrom
foda/webview2crash

Conversation

@Foda
Copy link
Copy Markdown
Contributor

@Foda Foda commented Apr 17, 2024

Description of Change

This PR removes the use of a 2nd "hidden" WebView2 that was used to parse and add a HTML base tag to the head tag when setting the HTML source of a WebView to a string.

This was done by appending the base tag script to the start of the user's HTML string, which the WebView then adds into the head element. While this is technically not valid HTML, all current browsers correct this behavior.

This is a work-around for the lack of being able to set the base URL when navigating to a string using WebView2 (MicrosoftEdge/WebView2Feedback#530).

As a bonus, using HtmlWebViewSource should now be 2x faster 😅

Issues Fixed

Fixes #21631

@Foda Foda requested review from PureWeen and jsuarezruiz April 17, 2024 21:51
@Foda Foda requested a review from a team as a code owner April 17, 2024 21:51
@dotnet-policy-service dotnet-policy-service bot added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 17, 2024
Copy link
Copy Markdown
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

LGTM but could we include an UITest loading a local html and validating that everything works comparing a snapshot (for example)?

@Foda Foda requested a review from jsuarezruiz April 22, 2024 22:41
@PureWeen PureWeen merged commit 440fa7f into main Apr 23, 2024
@PureWeen PureWeen deleted the foda/webview2crash branch April 23, 2024 21:57
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2024
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.

[windows] Account for ObjectDisposedException coming from device tests for MauiWebView

5 participants