You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Problem/Bug]: Application freeze after DPI change #4485
Our winforms application uses the System Aware DPI Mode.
Sometimes, users open the application on a screen using a certain DPI (ie. 100%) and then leave it open. They later get back to the app using a different setup (ie. a laptop with using a DPI of 125%).
If the user then reaches a WebView2 control, the containing form freezes and does not respond.
We had to put protections to prevent such interactions and ask the user to restart the application but it remains a patch.
We are in the process of converting our application to the PerMonitorV2 DPIAware mode which should resolve the problem.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
123.0.2420.65
SDK Version
1.0.2420.47
Framework
Winforms
Operating System
Windows 10
OS Version
19042.2965
Repro steps
Start the provided WindowsFormsAppWebView2Freeze program ;
Proceed to change the main screen DPI (ie. 100% => 150% or vice versa) ;
Click on the "Open WebView2" button.
Expected :
A new form opens and the web page is rendered correctly.
Actual :
A new form opens frozen and it is not possible to interact with it. Application needs to be killed.
Vincent Gentilcore (@vinnyduke) we've made some DPI related fixes in the last few months. Can you try your scenario with the latest WebView2 Runtime and see if the issue still reproes for you?
Unfortunately, I must recall my previous message. After further testing I discovered another scenario in which the issue still occurs. When DPI scaling is changed while a WebView2 process is running then client application gets into deadlock until WebView2 process is manually terminated via task manager. You may ask why DPI scaling is changed. It typicaly happens when a laptop display was set to let say 125 or higher value for better readability. Application misbehaves after docking laptop to larger LCD panel with 100% scaling. My primary concern is SAP GUI client which freezes. OWA MS Office applications show blurry text but continue working.
Regards
Marek Friedl
________________________________
Od: Friedl Marek ***@***.***>
Odesláno: úterý 29. října 2024 7:35
Komu: MicrosoftEdge/WebView2Feedback ***@***.***>
Předmět: Re: [MicrosoftEdge/WebView2Feedback] [Problem/Bug]: Application freeze after DPI change (Issue #4485)
Cool. It works now with the latest MS Edge (version 130.0.2849.56). Thank you for the effort.
Regars
Marek Friedl
GasNet, s.r.o.
Commercial Grid
IT Systems Analyst
Prosecká 855/68, 19000 Praha 9
M +420 739 537 583
E ***@***.******@***.***>
Does your client application contain non WebView2 content? In the deadlock scenario, are the parts outside of the WebView2 content not interactable? Are you able to interact with the title bar (drag the window, min/max, etc)?
When you get into that state, can you collect dumps of the msedgewebview2.exe process? In TaskManager, enable the command line column and collect a dump for the msedgewebview2.exe process whose command line starts with --embedded-browser-webview=1. Also collect a dump of your application process. Task manager can create dumps by right clicking the process and choosing "Create memory dump file".
Vincent Gentilcore (@vinnyduke) we've made some DPI related fixes in the last few months. Can you try your scenario with the latest WebView2 Runtime and see if the issue still reproes for you?
Updated to 130.0.2849. I confirm that i can still repro the issue with the same given steps.
Does your client application contain non WebView2 content? In the deadlock scenario, are the parts outside of the WebView2 content not interactable? Are you able to interact with the title bar (drag the window, min/max, etc)?
When you get into that state, can you collect dumps of the msedgewebview2.exe process? In TaskManager, enable the command line column and collect a dump for the msedgewebview2.exe process whose command line starts with --embedded-browser-webview=1. Also collect a dump of your application process. Task manager can create dumps by right clicking the process and choosing "Create memory dump file".
In my scenario, there are two forms : form1 and form2. Only the latter contains a WebView2 component.
When i get into that state :
I can fully interact with form1. I can close the app by closing that form (title bar).
I cannot interact at all with form2, including it's title bar.
Yes, it does contain non WebView2 content. In one scenario it is a modal dialog with two buttons (non WebView2) and text area with WebView2. When a deadlock occurs the whole dialog stops responding. I am not able to move it. It does not redraw itself after switching to another app and back. When I kill offended WebView2 process then the dialog becomes responsive again. Only the WebView2 text area is blank. Sorry, I not able to send dump in a safe manner. It may contain sensitive data from our ERP system.
Vincent Gentilcore (@vinnyduke), I took a look at the provided dumps, but I don't see any deadlocks in their process. From the dumps, it appears that both the app and WebView2 process are sitting in their message loop waiting for a new input/window message from the OS.
However, after looking again at your repro steps, I realized I overlooked that you are a System aware app where you change the monitor DPI scale before creating the WebView2. I believe you are hitting the same issue as #2611. I wrote a detailed comment there explaining the situation. #2611 (comment)
To quickly summarize, your app process is launched at System aware 100% scaling. When you change the DPI awareness to 150%, your app process still believes the System aware scale is 100% (and the OS bitmap scales your app). When you then create a WebView2, the WebView2 process is launched at System aware 150% scaling. This causes the HWND parenting to not work correctly, without the OS giving WebView2 any idea that it isn't supported. You can use the registry key to opt out of the per process System DPI scale, which should resolve your issue. Another option is to make your app PerMonitor DPI aware.
Glad to hear the registry key is working for you marek496. Vincent Gentilcore (@vinnyduke) let me know if you have any further questions about this. I'm going to close this issue.
Activity
bradp0721 commentedon Oct 28, 2024
Vincent Gentilcore (@vinnyduke) we've made some DPI related fixes in the last few months. Can you try your scenario with the latest WebView2 Runtime and see if the issue still reproes for you?
marek496 commentedon Oct 29, 2024
marek496 commentedon Oct 29, 2024
bradp0721 commentedon Oct 29, 2024
Does your client application contain non WebView2 content? In the deadlock scenario, are the parts outside of the WebView2 content not interactable? Are you able to interact with the title bar (drag the window, min/max, etc)?
When you get into that state, can you collect dumps of the msedgewebview2.exe process? In TaskManager, enable the command line column and collect a dump for the msedgewebview2.exe process whose command line starts with --embedded-browser-webview=1. Also collect a dump of your application process. Task manager can create dumps by right clicking the process and choosing "Create memory dump file".
vinnyduke commentedon Oct 29, 2024
Updated to 130.0.2849. I confirm that i can still repro the issue with the same given steps.
In my scenario, there are two forms : form1 and form2. Only the latter contains a WebView2 component.
When i get into that state :
Here are the requested dumps :
https://1drv.ms/u/s!Ahwkv4cFcZBugd0Vip2kIwrsYiPlwA?e=hjFUbD
marek496 commentedon Oct 30, 2024
Yes, it does contain non WebView2 content. In one scenario it is a modal dialog with two buttons (non WebView2) and text area with WebView2. When a deadlock occurs the whole dialog stops responding. I am not able to move it. It does not redraw itself after switching to another app and back. When I kill offended WebView2 process then the dialog becomes responsive again. Only the WebView2 text area is blank. Sorry, I not able to send dump in a safe manner. It may contain sensitive data from our ERP system.
bradp0721 commentedon Oct 30, 2024
Vincent Gentilcore (@vinnyduke), I took a look at the provided dumps, but I don't see any deadlocks in their process. From the dumps, it appears that both the app and WebView2 process are sitting in their message loop waiting for a new input/window message from the OS.
However, after looking again at your repro steps, I realized I overlooked that you are a System aware app where you change the monitor DPI scale before creating the WebView2. I believe you are hitting the same issue as #2611. I wrote a detailed comment there explaining the situation.
#2611 (comment)
To quickly summarize, your app process is launched at System aware 100% scaling. When you change the DPI awareness to 150%, your app process still believes the System aware scale is 100% (and the OS bitmap scales your app). When you then create a WebView2, the WebView2 process is launched at System aware 150% scaling. This causes the HWND parenting to not work correctly, without the OS giving WebView2 any idea that it isn't supported. You can use the registry key to opt out of the per process System DPI scale, which should resolve your issue. Another option is to make your app PerMonitor DPI aware.
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\WebView2Samples\SampleApps\WebView2WpfBrowser\bin\Debug\netcoreapp3.0\WebView2WpfBrowser.exe"="~ PERPROCESSSYSTEMDPIFORCEOFF"
marek496 commentedon Oct 31, 2024
All clear. For the time being the registry key quick fix is way to go. I am going to ask app vendor to make it display DPI aware.
bradp0721 commentedon Oct 31, 2024
Glad to hear the registry key is working for you marek496.
Vincent Gentilcore (@vinnyduke) let me know if you have any further questions about this. I'm going to close this issue.
v3(windows): add WindowsOptions.UseVisualHosting to fix WebView2 hang…