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

Application crash when moving/changing state on a Window after calling Close on WebView2 before it's unloaded #10219

Open
NicholasChrzan opened this issue Dec 6, 2024 · 4 comments
Labels
area-WebView bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@NicholasChrzan
Copy link

NicholasChrzan commented Dec 6, 2024

Describe the bug

If you call Close on a WebView2 control before the control has been unloaded and change the position of the window (changing Overlapped presenter in our case) the app will crash.

The root cause of this looks like the AppWindow.Changed event is unwired in the Unloaded event and not in the Close method. When the window position changes the NotifyParentWindowPositionChanged is called on the CoreWebViewController which causes an access violation which crashes the application.

I have a crash dump file if needed.

A workaround is to call the Close in the Unloaded event of the WebView2.

Steps to reproduce the bug

  1. Maximize window (OverlappedPresenter.Maximize)
  2. Call Close on WebView
  3. Restore Window (OverlappedPresenter.Restore)

Expected behavior

No response

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows 11 (23H2): Build 22631

Additional context

No response

@NicholasChrzan NicholasChrzan added the bug Something isn't working label Dec 6, 2024
Copy link

github-actions bot commented Dec 6, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Dec 6, 2024
@karkarl
Copy link
Contributor

karkarl commented Dec 12, 2024

This seems to be a dupe of #8395 that should have been resolved here: #8395 (comment)

Can you provide a crash dump or repro app, this may be a regression.

@karkarl karkarl added needs-author-feedback Asked author to supply more information. area-WebView and removed needs-triage Issue needs to be triaged by the area owners labels Dec 12, 2024
@NicholasChrzan
Copy link
Author

NicholasChrzan commented Dec 12, 2024

@karkarl We found this crash when moving from 1.4->1.6. I do have a crash dump, how can I upload it to you (it's not letting me attach it here)?

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Dec 12, 2024
@NicholasChrzan
Copy link
Author

Also. to clarify this isn't related to Window.Close() it's related to the WebView2.Close() method.

For looking at this in WinDbg:

The crash happens here when calling m_coreWebViewController.NotifyParentWindowPositionChanged();

Image

This AppWindow.Changed event is subscribed in the TryCompleteInitialization
Image

But it's only released in the OnUnloaded event
Image

If "WebView2.Close" is called before the OnUnloaded and the AppWindow changes position then m_coreWebViewController.NotifyParentWindowPositionChanged(); is called but since the WebView2 has been closed this is no longer allowed and will throw an access violation.

We were able to work around this by moving our call to Close into the unloaded event and the crash didn't occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-WebView bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

2 participants