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

[Bug]: CoreWebView2 NewWindowRequest event to open in the same webview is broken #4250

Closed
DotNet-Fan opened this issue Dec 20, 2023 · 18 comments
Assignees
Labels
bug Something isn't working regression Something used to work but doesn't anymore tracked We are tracking this work internally.

Comments

@DotNet-Fan
Copy link

DotNet-Fan commented Dec 20, 2023

What happened?

If you subscribe to the CoreWebView2 NewWindowRequest and in the handler if you set the e.hendled=true and set the e.NewWindow to the sender that is the current webview2 instance , it opens in a new popup rather than in the same webview2 instance. This was working earlier and the code is broken.

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

120.0.2210.77

SDK Version

Microsoft.UI.Xaml.Controls - v 2.8.6

Framework

WinUI2/UWP

Operating System

Windows 11

OS Version

Windows 11 64 - Microsoft Windows [Version 10.0.22621.2861]

Repro steps

  • In UWP App , add a webview2 control.

  • Then make sure that Corewebview2 is initialized using EnsureCoreWebView2Async call.

  • Once initialized in the CoreWebView2Initialized handler subscribe to CoreWebView2.NewWindowRequested event.

  • In the CoreWebView2.NewWindowRequested handler add the below code

                  e.Handled = true;
                      if (sender != null)
                          e.NewWindow = sender;
    
  • Navigate to www.pinterest.com and click on login.

  • Click on Google Login.

  • It opens a new window outside the main app instead of existing webview2

  • This was working earlier and the code is broken now.

Repros in Edge Browser

No

Regression

Regression in newer Runtime

Last working version (if regression)

Runtime: 114.0.1823.58

AB#48257884

@DotNet-Fan DotNet-Fan added the bug Something isn't working label Dec 20, 2023
@github-actions github-actions bot added the regression Something used to work but doesn't anymore label Dec 20, 2023
@Danielx64
Copy link

Not to hijack, also happened on wpf as well: #4224

@DotNet-Fan
Copy link
Author

DotNet-Fan commented Dec 20, 2023

@Danielx64 Saw your post , As this is a blocker for us , did you get any solution to fix this?

@Danielx64
Copy link

@Danielx64 Saw your post , As this is a blocker for us , did you get any solution to fix this?

I ended up downloading a preview runtime and providing that with my app. Not ideal but it fix it for the time being

@monica-ch monica-ch added the tracked We are tracking this work internally. label Dec 22, 2023
@DotNet-Fan
Copy link
Author

@monica-ch Any info on when the fix would be available in windows?

@yildirimcagri-msft
Copy link
Member

Hi, thanks for reporting this, we have identified the issue and will deploy the fix soon.

@Danielx64
Copy link

@yildirimcagri-msft will this also be fixed on the wpf version as well? I also reported this and my report received no new updates.

@monica-ch
Copy link
Contributor

@Danielx64 Yes this is going to be webview2 runtime change and fixes the issue in all frameworks. I'll link the issue to this thread and close the other issue.

@yildirimcagri-msft
Copy link
Member

@Danielx64, please see comment on the other issue for clarification, I've re-activated it.

@DotNet-Fan
Copy link
Author

@yildirimcagri-msft When is the fix expected to be deployed through Windows patches?

@yildirimcagri-msft
Copy link
Member

The fix is checked-in, please validate via Edge Canary runtime. We are looking to cherry-pick it to Edge 120, but cannot guarantee that approval can go through. Otherwise, the fix should be available in Edge 121 (currently Beta).

@Danielx64
Copy link

For me it looks like 120 got the update with the fix

@DotNet-Fan
Copy link
Author

@Danielx64 you mean 120.0.2210.133?

@monica-ch
Copy link
Contributor

Yes, the fix is in 120.0.2210.133+.

@Danielx64
Copy link

Correct @DotNet-Fan , I was on phone when I reported back.

@DotNet-Fan
Copy link
Author

DotNet-Fan commented Jan 18, 2024

@Danielx64 @monica-ch I have observed an issue where in the webview2 instance you subscribe to NewWindowRequested event and WindowCloseRequested , then on firsttime these handlers would be hit during open and close popup/window after setting the below code.

e.Handled = true;
                  if (sender != null)
                      e.NewWindow = sender;

But in the same webview2 instance if the popup/window is opened again and closed , newwindowrequested/WindowCloseRequested events are not fired second time.

Any Idea?

@monica-ch
Copy link
Contributor

@DotNet-Fan Have you seen this issue in previous runtimes?

@contactteckee
Copy link

@monica-ch I have checked now and it can be seen in previous runtimes as well.

@champnic
Copy link
Member

champnic commented Apr 3, 2024

Resolved in runtimes version 120.0.2210.133+.

@champnic champnic closed this as completed Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something used to work but doesn't anymore tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

8 participants