Skip to content
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

[net9.0] Merge main to net9.0 #23585

Merged
merged 4 commits into from
Jul 12, 2024
Merged

[net9.0] Merge main to net9.0 #23585

merged 4 commits into from
Jul 12, 2024

Conversation

rmarinho
Copy link
Member

Description of Change

Update net9.0 with needed changes to deploy

jonathanpeppers and others added 4 commits July 11, 2024 12:35
Fixes: #20283
Fixes: #22972
Context: https://github.com/davide-cavallini/webview-winUI-maui-leak

The above sample on Windows was leaking because it does the following:

1. Your app has a single `Window`

2. Navigate to a page with a `WebView`

3. Navigate away

Because the `Window` remains alive, `WebViewHandler` subscribes
to `Window.Closed` which keeps a reference to the `WebView` and
keeps it alive indefinitely.

I was able to reproduce this in a test, that keeps the `Window`
alive before calling `AssertionExtensions.WaitForGC()`.

The solution was to move the `Window.Closed` subscription to the
`WebView2Proxy` nested class. This makes sure that the `WebView`,
its handler, etc. can be collected *before* the `Window` is closed.

I also found a secondary issue while debugging, if you call:

    webView.Close(); // MauiWebView or WebView2

If `CoreWebView2` is not initialized, it will throw a C++ exception.

We can instead do:

    if (webView.CoreWebView2 is not null)
    {
        webView.Close();
    }
The problem was that the body of the IF statement is considered one "line" and all environment variables are replaced before that "line" is executed. So set commands don't have an effect on the rest of the code in that IF.
Changed this to use `enabledelayedexpansion` and the `!!` syntax which makes it work the way would would expect.

One additional fix, enclose the set commands in quotation marks. This fixes a bug where if the `PATH` contains a parenthesis, the script would just plain fail (which can happen if one has x86 programs in their PATH).
@rmarinho rmarinho requested a review from a team as a code owner July 12, 2024 15:40
@rmarinho rmarinho merged commit 4784931 into net9.0 Jul 12, 2024
110 of 112 checks passed
@rmarinho rmarinho deleted the merge-main-net9 branch July 12, 2024 18:33
@samhouts samhouts added the fixed-in-net9.0-nightly This may be available in a nightly release! label Aug 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-net9.0-nightly This may be available in a nightly release!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants