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
In our WinForms WebView2 application, when we enable the PerMonitorV2 DPI awareness mode (via ApplicationHighDpiMode) and then test on a workstation with multiple monitors set to different scaling percentages, the screen details returned by a call to await getScreenDetails(); are incorrect and also change depending on which monitor the application is showing on.
For example, I have two 1920x1080 monitors oriented horizontally, with my primary display on the left. When I set the scale of the primary monitor to 150% and launch my application on that display, the web application sees two 1280x720 screens with the same 1.5 devicePixelRatio, with one offset -360 pixels vertically from the other:
If I then move the application to my second, unscaled monitor, the devicePixelRatio changes to 1, and now the web application sees two 1920x1080 monitors, the right one still vertically offset but now horizontally overlapping the first display with a left value of 1280:
Edge does not have this problem. Regardless of which monitor the browser is on, it reports the primary screen as 1280x720 with a devicePixelRatio of 1.5, and the secondary screen as 1920x1080 with a devicePixelRatio of 1 (the negative offset remains; I am assuming Chromium chooses to bottom-align screens in this layout):
So the available layout seen by the web application is all over the place. If it wants to launch a second window with a size or position relative to the screen, like for example right-aligning the window on the primary display, it's going to send over values that will depend on where the web application is at that moment. Because this looks like a bug I am hesitant to write .NET code to interpret size and position based on the location of the WebView2 control requesting the new window, which might later change with a update.
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
128.0.2739.79
SDK Version
1.0.2739.15
Framework
Winforms
Operating System
Windows 11
OS Version
22631.4169
Repro steps
You'll need a workstation with two or more monitors to test this out.
In Control Panel -> Display Settings, set the Scale value for your primary display to 150%
Launch the application on the primary, scaled display
Open Task Manager to the Details tab, add the DPI Awareness column, and confirm the application is running in "Per-Monitor (v2)" DPI awareness mode
Put focus in the MSN website and press F12 to bring up the DevTools
In the Console, execute: await window.getScreenDetails();
Expand the ScreenDetailed objects and see they incorrectly have the same 1.5 devicePixelRatio and dimensions, and one display is vertically offset from the other
Move the application to the unscaled display
Back in the DevTools Console, execute: await window.getScreenDetails();
Expand the ScreenDetailed objects again and see the devicePixelRatio has changed to 1, the dimensions of both screens have grown to their device size, they're still vertically offset, and they now horizontally overlap
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Thanks for reporting this @awolbach. Looks like this is the same issue as #4551 which you have already found. I will close this issue for tracking purposes.
I see #4551 as specifically describing an issue with the types of the left and top window feature arguments. What I'm describing here is that the virtual screen arrangement presented by WebView2 to the website seems incorrect when the primary display is scaled. Edge reports different screen details for the same configuration which seems like a clear bug.
After I posted this though, I noticed https://www.w3.org/TR/window-management/ is only a working draft, so you tell me if WebView2 is not intended to conform to it yet.
I'll reopen this as distinct. You're right @awolbach this is an issue about the reported screen position and the other issue is about the window position. That's my mistake.
WebView2 behavior should align with Edge's. So even if the standard is a working draft, if the browser appears to implement it properly WebView2 should too. I'll put this on our backlog.
What happened?
In our WinForms WebView2 application, when we enable the PerMonitorV2 DPI awareness mode (via ApplicationHighDpiMode) and then test on a workstation with multiple monitors set to different scaling percentages, the screen details returned by a call to
await getScreenDetails();
are incorrect and also change depending on which monitor the application is showing on.For example, I have two 1920x1080 monitors oriented horizontally, with my primary display on the left. When I set the scale of the primary monitor to 150% and launch my application on that display, the web application sees two 1280x720 screens with the same 1.5 devicePixelRatio, with one offset -360 pixels vertically from the other:
If I then move the application to my second, unscaled monitor, the devicePixelRatio changes to 1, and now the web application sees two 1920x1080 monitors, the right one still vertically offset but now horizontally overlapping the first display with a left value of 1280:
Edge does not have this problem. Regardless of which monitor the browser is on, it reports the primary screen as 1280x720 with a devicePixelRatio of 1.5, and the secondary screen as 1920x1080 with a devicePixelRatio of 1 (the negative offset remains; I am assuming Chromium chooses to bottom-align screens in this layout):
So the available layout seen by the web application is all over the place. If it wants to launch a second window with a size or position relative to the screen, like for example right-aligning the window on the primary display, it's going to send over values that will depend on where the web application is at that moment. Because this looks like a bug I am hesitant to write .NET code to interpret size and position based on the location of the WebView2 control requesting the new window, which might later change with a update.
Here's a simple sample app to repro the problem:
WebView2PerMonitorV2.zip
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
128.0.2739.79
SDK Version
1.0.2739.15
Framework
Winforms
Operating System
Windows 11
OS Version
22631.4169
Repro steps
You'll need a workstation with two or more monitors to test this out.
await window.getScreenDetails();
await window.getScreenDetails();
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response
AB#54587017
The text was updated successfully, but these errors were encountered: