MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
449 stars 53 forks source link

[Problem/Bug]: Webview2 Not position on High scaled monitor when gdiScaling is DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED #4459

Open dandy518 opened 6 months ago

dandy518 commented 6 months ago

What happened?

If the monitor scaled is over 100% and the SetProcessDpiAwarenessContext setting is DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED, there is a problem that the rendering window is misplaced, so is there a solution?

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

122.0.2365.92

SDK Version

2470.0

Framework

Win32

Operating System

Windows 10

OS Version

No response

Repro steps

  1. DpiUtil::SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED)
  2. Sample Program Run

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

AB#50881859

johna-ms commented 5 months ago

@dandy518 could you provide test app/code? I set a local app to DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED and the window is positioned correctly.

dandy518 commented 5 months ago

@johna-ms Hi. I used code https://github.com/MicrosoftEdge/WebView2Samples/tree/main/SampleApps/WebView2APISample Did you set the monitor scaled to 100% over? display-scaling

johna-ms commented 5 months ago

Yes. Could you share a screenshot of the window misplacement?

dandy518 commented 5 months ago

@johna-ms image

johna-ms commented 5 months ago

Ok I am seeing this repro for visual hosting. Could you confirm if you are using normal windowed mode hosting? Does this repro when launching the sample app normally? Or are you changing the hosting mode by navigating to the 'window' submenu?

dandy518 commented 5 months ago

@johna-ms Use normal window.

I'm only using the sample app(WebView2APISample) by changing it as below.

int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) { g_hInstance = hInstance; UNREFERENCED_PARAMETER(hPrevInstance); g_nCmdShow = nCmdShow;

// Default DPI awareness to PerMonitorV2. The commandline parameters can
// override this.
**DPI_AWARENESS_CONTEXT dpiAwarenessContext = DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED;// DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2;**

..... }

champnic commented 5 months ago

@dandy518 what specific version of Win10 are you on? The Windows team put in a fix for this for Win11, but I'm not sure if it got backported to Win10 or all Win10 versions.

IceReaper commented 5 months ago

Our customer reports the same problem with his software on windows 10 (22H2) machines :( Subscribing to this issue.

dandy518 commented 5 months ago

@champnic Hi. Sorry for the late reply. Win10 version is 22H2 19045.4046

champnic commented 5 months ago

Are you able to see the same problem if you run on Win11?

IceReaper commented 5 months ago

Our software works on all win11 machines flawless. Only windows 10 machines (22h2) have the issue. Sadly our company (software development) has win 11 rolled out. But the customer has windows 10 rolled out. And there is no way for us to downgrade or the customer to upgrade. Well one day they will upgrade to Windows 11 of course, but as for a lot of large global companies (like this customer), IT progress is quite behind when it comes to installing the latest versions. Win 10 + .net 6 it is here for the next overseeable time. And no way to delay the software release till they use windows 11 :(

dandy518 commented 5 months ago

@champnic There's also a problem with win11

image

image

champnic commented 4 months ago

@dandy518 @IceReaper Thanks for confirming. This all matches that Windows put in a fix, but they haven't backported it to earlier versions. @dandy518 I assume if you updated your Windows 11 version you would see this start to work correctly.

I'll try to push on the Windows team to backport this fix. Thanks!

champnic commented 4 months ago

Confirmed that Windows had found a remaining issue on Win10 and has checked in a fix as of April. It looks like it should be part of a servicing update around July 2024.