-
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
[Problem/Bug]: NavigationCompleted is not invoked since 125.0 #4579
Comments
Is it for any url or some particular one? Are other navigation events getting called? |
Hi there Thanks for the quick reply. Even when both URLs are exactly the same, I'll test the other ones in a few hours |
I have tried to navigate to wikipedia in our wpf sample app with runtime 125.0.2535.51 and I see NavigationCompleted events both times - there should be something else. Do you able to repro it in our sample app? Which public url do you see it? |
I'll try that once I'm in the office in a few hours and report back at you. |
Sorry for the late reply. So heres the case. However I still only get the NavigationStarting in our application. WebView2.CoreWebView2InitializationCompleted += (_, arg) =>
{
if (WebView2?.CoreWebView2 is null)
{
RedirectToWebviewDownload();
return;
}
WebView2.CoreWebView2.Settings.AreDevToolsEnabled = false;
WebView2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
WebView2.CoreWebView2.Settings.IsStatusBarEnabled = false;
WebView2.CoreWebView2.Profile.PreferredColorScheme = CoreWebView2PreferredColorScheme.Light;
WebView2.CoreWebView2.SourceChanged += (_, _) => log.WriteLine("---> SourceChanged");
WebView2.CoreWebView2.ContentLoading += (_, args) => log.WriteLine($"---> ({args.NavigationId}) ContentLoading {(args.IsErrorPage ? string.Empty : "(ErrorPage)")}");
WebView2.CoreWebView2.HistoryChanged += (_, _) => log.WriteLine("---> HistoryChanged");
WebView2.CoreWebView2.DOMContentLoaded += (_, args) => log.WriteLine($"---> ({args.NavigationId}) DOMContentLoaded");
WebView2.CoreWebView2.NavigationCompleted += (_, args) => log.WriteLine($"---> ({args.NavigationId}) NavigationComplete "
+ $"{(args.IsSuccess ? "(success)" : "(error)")} - {args.WebErrorStatus.ToString()} - {args.HttpStatusCode}");
initWebview2.TrySetResult(arg);
};
...
public Uri InvokeBrowserNavigation(string uri, string callbackUri, StreamWriter logger)
{
log ??= logger;
var navigationTask = new TaskCompletionSource<CoreWebView2NavigationStartingEventArgs>();
var taskCanceled = false;
WebView2.NavigationStarting += WaitForNavigationCallback;
Dispatcher.InvokeAsync(async () =>
{
environment ??= await WebView2.CreateUserEnvironment();
if (environment is null)
{
RedirectToWebviewDownload();
return;
}
await WebView2.EnsureCoreWebView2Async(environment);
await initWebview2.Task.ConfigureAwait(false);
WebView2.CoreWebView2.Navigate(uri);
});
// This block waits for the navigating event without
// blocking the ui thread. (Source: Mark Zachmann)
var frame = new DispatcherFrame();
new Thread(() =>
{
try
{
navigationTask.Task.Wait(cancellationTokenSource.Token);
Dispatcher.Invoke(() => Hide());
Task.Delay(500).Wait(cancellationTokenSource.Token);
}
catch (OperationCanceledException e)
{
Log.GetLog().Warning(e, "Navigation canceled.");
taskCanceled = true;
}
finally
{
frame.Continue = false;
}
}).Start();
Dispatcher.PushFrame(frame);
WebView2.NavigationStarting -= WaitForNavigationCallback;
if (taskCanceled)
throw new OperationCanceledException("Authentication canceled by user.");
return new Uri(currentNavigatioTarget);
void WaitForNavigationCallback(object sender, CoreWebView2NavigationStartingEventArgs e)
{
log.WriteLine($"NavigationStarting{(e.IsRedirected ? " (redirect)" : string.Empty)} '{e.Uri}'");
if (!e.Uri.StartsWith(callbackUri))
return;
currentNavigatioTarget = e.Uri;
navigationTask.TrySetResult(e);
}
} log
When I try the navigations within the SampleRepo both events occur private void ExecutePkce(object sender,
ExecutedRoutedEventArgs e)
{
var token = "idToken";
webView.CoreWebView2.NavigationStarting += (_, args) => Console.WriteLine($"{args.NavigationId} NavigationStarting {token} {args.Uri} ");
webView.CoreWebView2.NavigationCompleted += (_, args) => Console.WriteLine($"{args.NavigationId} NavigationComplete {token}");
const string urlId = "https://sts.cmiag.dev/dev/identity/connect/authorize?client_id=metatool&response_type=id_token&scope=openid+profile&redirect_uri=oob%3A%2F%2Fmetatool%2Fcallback&state=7e998b8f0d1f404a8f2edca02459eb2e&nonce=6fdf4f8bdbc04f6786aa356399a5f405&acr_values=tenant%3Adev+manual_scheme_selection%3AFalse";
const string urlToken =
"https://sts.cmiag.dev/dev/identity/connect/authorize?client_id=metatool&response_type=token&scope=metatool&redirect_uri=oob%3A%2F%2Fmetatool%2Fcallback&state=e98b832686ff4d98afbfa6c9707c86ed&acr_values=tenant%3Adev+manual_scheme_selection%3AFalse";
webView.CoreWebView2.Navigate(urlId);
token = "accessTOken";
webView.CoreWebView2.Navigate(urlToken);
} |
What happened?
Today the WebView2 Runtime was updated from
124.0.2478.97
to125.0.2535.51
.I use
Microsoft.Web.WebView2
in my WPF application.When I call
CoreWebView2.Navigate(uri);
for the first time, theNavigationCompleted
is invoked as expected.When I call
Navigate
second time only theNavigationStarting
event gets invoked.Sample Code
Importance
Blocking. My app's basic functions are not working due to this issue.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
125.0.2535.51
SDK Version
1.0.2478.35
Framework
WPF
Operating System
Windows 10, Windows 11, Windows Server
OS Version
22631.3447
Repro steps
Invoke
CoreWebView2.Navigate(uri);
twiceonly the first NavigationCompleted event is invoked
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Regression in newer Runtime
Last working version (if regression)
SDK 1.0.1661.34, Runtime 124.0.2478.97
The text was updated successfully, but these errors were encountered: