-
Notifications
You must be signed in to change notification settings - Fork 51
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
Unable to get callbacks via add_WebResourceRequested for WebView2 created via add_NewWindowRequested #616
Comments
Thanks for the report, I've added this bug to our backlog! |
Hi, if I understood your issue correctly, I can see the WebResourceRequested events firing on a opened WebView so I cannot repro this. Are you calling AddWebResourceRequestedFilter separately and adding a separate WebResourceRequested handler on the new WebView that you created for the NewWindowRequested as well? Otherwise, it would be good to see some sample code from your side to understand the issue better. |
We create a new controller and WebView2 window. The new window is setup separately with filter and callbacks. The callbacks for web requests are never called. |
Did some more experiements and when I added this to NavigationComplete it works...
|
Something is call order dependant. By accident I discovered that half-way in some refactoring the callback started working when I manually reloaded after initial failure. Now I've a workaround where the callback for NavicationComplete reinstalls the filters (see example above) and then reloads. This workaround is protected by an internal counter to avoid potentially infinite loop Maybe this information can help you pinpoint the underlying problem... |
Same workaround us now also used for adding host objects for |
This should be fixed in runtimes version 92.0.886.0+. Thanks! |
This still doesn't work. I tested it with both runtime 92.0.902.62 + SDK 1.0.902.49 and Edge Dev 93.0.961.10 + SDK 1.0.955-prerelease. There are 3 major issues with the first navigation in a child window:
Note that all 3 issues only occur during the initial navigation and are gone in subsequent documents (either through page reload or navigations to new locations. Our scenarios depend on working around issues 2) and 3). If you fixed them, it would make my life a lot easier. However, if you finally fix issue 1), I could at least implement an elegant workaround for issues 2) and 3) by intercepting the web request for the first navigation and providing an artificial response containing a script which reloads the page. |
@Kay-Burchardt - can you please share details how you have fixed the 2nd issue. I am also facing same challenge with child window window.chrome.webview is not initialized. So, I am unable to communicate from java script to c#. Can you please help me on this |
We use a callbackhook via
add_WebResourceRequested
for adding request headers and serving some content from local folders.This works perfect until we try to use windows created via
window.open
.Exactly the same code for hosting a second WebView2 in a separate dialog does not give any callbacks for requests when sent back via
put_NewWindow
. Other callbacks, like navigation and dev protocol, works perfect. Navigating works also, minus our headers and local content.Attaching multiple callbacks via
add_WebResourceRequested
in our code yields similar behaviour. Our suspision is that (conflicting) callbacks are used internally.Version
SDK: 1.0.622.22 (GA)
Runtime: GA
Framework: Win32
OS: Win10
The text was updated successfully, but these errors were encountered: