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

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

Open
dandy518 opened this issue Mar 28, 2024 · 14 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@dandy518
Copy link

dandy518 commented Mar 28, 2024

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

@dandy518 dandy518 added the bug Something isn't working label Mar 28, 2024
@dandy518 dandy518 changed the title [Problem/Bug]: [Problem/Bug]: Webview2 Not position on High scaled monitor when gdiScaling is DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED Mar 28, 2024
@johna-ms
Copy link
Contributor

@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
Copy link
Author

@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
Copy link
Contributor

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

@dandy518
Copy link
Author

@johna-ms
image

@johna-ms
Copy link
Contributor

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?

@johna-ms johna-ms added the tracked We are tracking this work internally. label May 14, 2024
@dandy518
Copy link
Author

@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
Copy link
Member

@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
Copy link

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

@dandy518
Copy link
Author

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

@champnic
Copy link
Member

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

@IceReaper
Copy link

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
Copy link
Author

@champnic There's also a problem with win11

image

image

@champnic
Copy link
Member

@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
Copy link
Member

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.

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

4 participants