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

WebView2 freezes after logging in to facebook. #3488

Closed
NicatQaraxanov opened this issue May 16, 2023 · 36 comments
Closed

WebView2 freezes after logging in to facebook. #3488

NicatQaraxanov opened this issue May 16, 2023 · 36 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@NicatQaraxanov
Copy link

NicatQaraxanov commented May 16, 2023

Description
When I try to log in to Facebook, WebView2 occasionally freezes. I can't determine the exact cause, but I've noticed a possible correlation with requests for notification permissions; when a website requests these permissions, it tends to freeze. Conversely, when the website does not request notification permissions, it operates normally. While I'm not entirely certain that this is the cause, it's a potential lead. Moreover, this issue only occurs when I'm logging into Facebook. Everything works normally on the login page.

Version
WebView2: 1.0.1774.30
Framework: WinForms.
OS: Win10.

Screenshots
image
Here you can see that this happens and after this WebView just stops working.

AB#44688481

@NicatQaraxanov NicatQaraxanov added the bug Something isn't working label May 16, 2023
@novac42
Copy link
Contributor

novac42 commented May 16, 2023

Thanks for reporting the issue. I've assigned this to a dev who can help follow up on this.

@hazem-it
Copy link

same error

@ElyssaJyu
Copy link

Hi @NicatQaraxanov @hazem-it, I simply navigate to Facebook website in our WinForms sample app. I successfully logged in and receive notification on my test. Could you give more details about your scenario? so I can address the root cause. Thanks.

@NicatQaraxanov
Copy link
Author

NicatQaraxanov commented May 17, 2023

@ElyssaJyu error occurs every time Facebook attempts to display a white overlay with a popup, which I suspect is caused by a certain JavaScript call. This popup and overlay don't appear every time you log in, only the very first time and if you have cleaned your cache and cookies. You might see this popup in Edge browser's private mode.

By popup i mean this
image

And here additional video about what happens.
https://github.com/MicrosoftEdge/WebView2Feedback/assets/109304730/ce48d59c-c69d-4644-ad05-a23d6caf78f9

@hazem-it
Copy link

Hi @NicatQaraxanov @hazem-it, I simply navigate to Facebook website in our WinForms sample app. I successfully logged in and receive notification on my test. Could you give more details about your scenario? so I can address the root cause. Thanks.

You need to delete all files created by the browser before trying again
I will take a video of the problem and send it to you

@hazem-it
Copy link

Untitled.mp4

@NicatQaraxanov
Copy link
Author

@hazem-it yes, that is exactly what happens on my application too.

@RK-BAKU
Copy link

RK-BAKU commented May 17, 2023

Hi @NicatQaraxanov @hazem-it, I simply navigate to Facebook website in our WinForms sample app. I successfully logged in and receive notification on my test. Could you give more details about your scenario? so I can address the root cause. Thanks.

You need to delete all files created by the browser before trying again I will take a video of the problem and send it to you

I've got the same error. Looks like a bug.

@ElyssaJyu
Copy link

Thanks for provided details. I tracked as a bug internally and investigate it. I will async with you when there is a fix. Thanks.

@ElyssaJyu ElyssaJyu added the tracked We are tracking this work internally. label May 18, 2023
@ElyssaJyu
Copy link

ElyssaJyu commented May 26, 2023

Hi, I haven't been able to completely reproduce the issue based on your scenario, but I have encountered a similar freeze situation on my end. I would like to confirm a few details:
@NicatQaraxanov @hazem-it, from your screenshots, it seems webview2 is freeze, the toolbar is still on the top of the page, and DevTools is running.
From @hazem-it, it seems webview2 is crash, when logging in Facebook.

  1. Which runtime and SDK are you using?
  2. Does the freeze lead to WebView2 disposal? Could you confirm whether the WebView2 process is still initialized when the freeze occurs?
  3. Is there any exception thrown? Could you check the crash dumps? It can usually be found in the app's user data folder. \EBWebView\Crashpad\reports
  4. It seems webview2 occasionally freezes on your scenario. Does this only happen after requesting notification permission?
  5. Currently, notifications are disabled in WinForms. Have you triggered the PermissionRequested event to re-enable them?

Thanks for the incoming feedbacks.

@johnasebok
Copy link

I have the same issue when trying using it in a WPF application. First time logging into facebook it crashes the entire program. After log in is cached, subsequent loading of the page cause only the control to stop working. The webview2 does not appear to be disposed but does become invalid. I can still access it via code. When trying to set a new source for it, it throws the following error.

System.InvalidOperationException: 'The WebView control is no longer valid because the browser process crashed.To work around this, please listen for the CoreWebView2.ProcessFailed event to explicitly manage the lifetime of the WebView2 control in the event of a browser failure.https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.processfailed'

The CoreWebView2.ProcessFailed event returns the following:

<title>Document</title>
  Name Value Type
e {Microsoft.Web.WebView2.Core.CoreWebView2ProcessFailedEventArgs} Microsoft.Web.WebView2.Core.CoreWebView2ProcessFailedEventArgs
  ExitCode -1073741819 int
  FrameInfosForFailedProcess null System.Collections.Generic.IReadOnlyList<Microsoft.Web.WebView2.Core.CoreWebView2FrameInfo>
  ProcessDescription "" string
  ProcessFailedKind BrowserProcessExited Microsoft.Web.WebView2.Core.CoreWebView2ProcessFailedKind
  Reason Unexpected Microsoft.Web.WebView2.Core.CoreWebView2ProcessFailedReason

@NicatQaraxanov
Copy link
Author

Hi @ElyssaJyu,

Thank you for your detailed feedback and observations. I'll attempt to address your queries as concisely as possible:

  1. For your first question, the runtime version being utilized in my project is 4.7.2 and the SDK version is 7.0.101.
  2. As for the second question, it appears that the WebView2 instance is not getting disposed when the freeze occurs. The freeze seems to only affect the view while leaving the underlying processes intact. I can confirm this as I can still perform operations on the WebView2 object via code.
  3. Yes, I have noticed exceptions being thrown, which are logged in the Crashpad/reports. Specifically, I am seeing an exception with Code: 0xc0000005. The information attached with this exception states, "The thread tried to read from or write to a virtual address for which it does not have the appropriate access." This seems to occur post the freezing of WebView2.
  4. With respect to your fourth question, indeed, it appears that WebView2 occasionally freezes after a request for notification permission. When the request isn't made, I don't experience such freezes. However, I must clarify that I cannot assert with absolute certainty that the request for notification permission is the sole trigger for this freeze.
  5. Finally, addressing your last question, I have indeed tried handling the PermissionRequested event by returning true/false for each permission request. Unfortunately, this approach did not yield any improvement to the situation.

I hope this information proves helpful in understanding the issue at hand better, and I look forward to any insights or solutions you might be able to suggest.

@NicatQaraxanov
Copy link
Author

@johnasebok did approach with CoreWebView2.ProcessFailed help? WebView2 stopped freezing?

@ElyssaJyu
Copy link

ElyssaJyu commented May 30, 2023

Hi @NicatQaraxanov,

  1. For your first question, the runtime version being utilized in my project is 4.7.2 and the SDK version is 7.0.101.

this seems your .net version and framework. I'd like to clarify your WebView2 runtime and SDK version. Your can find SDK version from NuGet package manager in your project and using CoreWebView2Environment.GetAvailableBrowserVersionString(String) Method to find runtime version.
Could you upgrade to the newest version to see whether the freeze can be resolved?

  1. When a WV2 process fails, it fires a ProcessFailed event. You can define what actions to take when such a failure occurs, e.g., logging the error or attempting to recover from the failure.

  2. To be confirmed, it seems, in your scenario, webview2 browser process doesn't crash, but freezes. WebView2 sometimes freezes when a request for notification permission is made. If you didn't request the notification permission, the freeze won't happen.

Thanks

@NicatQaraxanov
Copy link
Author

@ElyssaJyu the SDK version is mentioned on my very first message in this issue (WebView2: 1.0.1774.30). It is latest.
Runtime: 113.0.1774.57

@NicatQaraxanov
Copy link
Author

NicatQaraxanov commented May 30, 2023

@ElyssaJyu The ProcessFailed event has been triggered, providing the same information as @johnasebok mentioned. However, once the process has failed, how can I recover from it? I have tried to recreate the WebVeiw instance and all but it didn't work. Same error happening again.

@ElyssaJyu
Copy link

@NicatQaraxanov. I'm trying to find a workaround, will post it ASAP. Sorry for that inconvenience.

@NicatQaraxanov
Copy link
Author

@ElyssaJyu Thank you for your response. I appreciate your effort in finding a workaround and your commitment to resolving the issue. Take your time. I look forward to hearing from you as soon as possible.

@ElyssaJyu
Copy link

ElyssaJyu commented May 30, 2023

Hi @NicatQaraxanov. I find a potential workaround. Please try to disable this Web App Widgets. Could you confirm whether it will work? I'm still working on finding the root cause. Thanks.
e.g. CoreWebView2EnvironmentOptions.AdditionalBrowserArguments= "--disable-features=msWebAppWidgets"

@NicatQaraxanov
Copy link
Author

@ElyssaJyu Thank you for providing the workaround! I appreciate your efforts in finding a solution. I have tried disabling the Web App Widgets as you suggested, and I'm happy to inform you that it has successfully resolved the problem.

@johnasebok
Copy link

johnasebok commented May 30, 2023

Thanks @ElyssaJyu that works for me. The WPF control doesn't seem to have an option to set the CoreWebView2EnvironmentOptions.AdditionalBrowserArguments. So just I used:
Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--disable-features=msWebAppWidgets");

And viola! It no longer crashes.

@NicatQaraxanov
Copy link
Author

Hi @ElyssaJyu! I have a quick question. Does disabling Web App Widgets affect WebView2 performance? I'm not entirely certain, but I believe I might experience some performance loss after disabling the Web App Widgets. For example, when visiting YouTube and so on.

@ElyssaJyu
Copy link

Hi @NicatQaraxanov, I don't think disabling this feature should affect WebView2 performance, could you provide some details about performance loss you faced? Thanks

@NicatQaraxanov
Copy link
Author

@ElyssaJyu I cant say 100% if its happening because of Web App Widgets. I will ping you after i gain much more information about this problem. Thank you for your response :)

@ElyssaJyu
Copy link

Hi, the issue has been fixed in webview2 runtime 114+, and new version has been released.

@NicatQaraxanov, I will close this issue since webview2 freeze has been fixed. If any further issue with webview2 performance, please either reopen this case or open a new one, and notify me, thank you.

@NicatQaraxanov
Copy link
Author

NicatQaraxanov commented Jun 6, 2023

Hi @ElyssaJyu! When I disable Web App Widgets and try to enter YouTube, it freezes sometimes. Could you please check it?

@ElyssaJyu
Copy link

@NicatQaraxanov Hi, have you upgraded the runtime to 114 version? In the latest version, you don't need to disable the Widgets feature to avoid webview2 freezing. Please let me know if WebView2 still freezes occasionally in the 114+ without disabling behavior. Thanks

Also, I have reached out the feature team, currently, the crash when manually disabling widgets is an understood behavior that should not be impacting any users who are not manually passing command line flags. The team will make some change on this feature in the near future.

@NicatQaraxanov
Copy link
Author

Do you mean installing the latest version on WebView2 from nuget package manager @ElyssaJyu? The latest is 1.0.1823.32

@ElyssaJyu
Copy link

NuGet package is for WebView2 SDK. If you use Evergreen distribution mode, it's automatically up to date; if fixed version mode, please try to manually upgrade it.
You can use webView.CoreWebView2.BrowserVersionString to check the version. Or check the webview2 process property in Task Manager.

@Ychyi1
Copy link

Ychyi1 commented Jan 8, 2024

I also encounter the same issue; when I try to open the Facebook website, it becomes unresponsive.

WebView2 Runtime Evergreen Bootstrapper
120.0.2210.121
C:\Program Files (x86)\Microsoft\EdgeWebView\Application\120.0.2210.121\msedgewebview2.exe

@tekmun
Copy link

tekmun commented Jan 9, 2024

Hi, I encounter a WebView2 freezing in my app when I open the Facebook website for authentication.

WebView2 Runtime version is 120.0.2210.121, taken from Settings -> Apps -> Installed Apps.

Now, I am no longer able to sign into Facebook from my app.

@ixiaokang
Copy link

I also encounter the same issue; when I try to open the Facebook website, it becomes unresponsive.

WebView2 Runtime Evergreen Bootstrapper
120.0.2210.121
C:\Program Files (x86)\Microsoft\EdgeWebView\Application\120.0.2210.121\msedgewebview2.exe

@ElyssaJyu ElyssaJyu reopened this Jan 9, 2024
@ElyssaJyu ElyssaJyu assigned victorhuangwq and unassigned ElyssaJyu Jan 9, 2024
@HoangPhiHung0618
Copy link

I am experiencing a similar issue

@didess27
Copy link

didess27 commented Jan 9, 2024

Hi, I have the same issue. My app worked in December 2023, now it stopped showing the facebook site, other sites are working so far. I also tried to use the code from the WebView2Samples but the same problem there with facebook.
Our clients use the app so a workaround or a solution would be very helpful. Thank

@victorhuangwq
Copy link
Collaborator

Hi @Ychyi1 @HoangPhiHung0618 @didess27 @ixiaokang @tekmun, the issue you are facing is actually a new / different bug, tracked in the following GitHub issue.

#4281

The issue is fixed in Edge Canary 122.0.2330.0+. Could you please test with Canary channel and validate the fix?

@victorhuangwq
Copy link
Collaborator

victorhuangwq commented Jan 9, 2024

In the meantime, I am closing this issue as it's solved, and the new issue is tracked in #4281

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests