-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Feature Request - Add BrowserSubProcess DpiAwareness Option #2927
Comments
Should also add note that |
It might make sense to default the browsersubprocess DPI awareness to that of the main application, see how feasible that is. |
Bumping this to the As a short-term workaround use the |
|
Documentation rewrite add reference to https://docs.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process#setting-default-awareness-with-the-application-manifest Doc Rewrite (WIP)High DPI Displays/SupportDesktop applications using Note If you mouse cursor is incorrectly positioned in the browser or the browser displays black boxes/border with rendering/resizing then your app needs to be made There are two main methods to specify the default DPI awareness of a process:
WinForms High DPIApp.manifestSet the default awareness using the application manifest. The following example is PerMonitor DPI Aware on Win 10 1703 and above and PerMonitor DPI aware on older version. Make sure you read https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows#dpi-awareness-mode which discusses the different
ProgramaticallySetting High DPI in code you can use the Cef.EnableHighDPISupport(); helper method. This calls the Cef.EnableHighDPISupport(); must be called very early on in your application execution, preferably in your application entry point (Program.Main). The CefSharp.MinimalExample.WinForms project contains a working example. WPF High DPIApp.manifestAdd the relevant
Programatically
OffScreen High DPIAdd the relevant High DPI Additional Info
var settings = new CefSettings();
settings.CefCommandLineArgs.Add("disable-gpu-compositing");
Cef.Initialize(settings); Alternatively you can try the force-device-scale-factor command line flag. var settings = new CefSettings();
settings.CefCommandLineArgs.Add("force-device-scale-factor", "1");
Cef.Initialize(settings);
|
The Once this feature has been complete additional details will need to be added. |
FYI, I fixed this issue for my projects by modifying the manifest in CefSharp.BrowserSubprocess.EXE to match my main applications DPI awareness. I gave the EXE a different name and set the BrowserSubprocessPath property accordingly. |
Be careful copying the Browsersubprocess and renaming it as I've seen previous cases where antivirus software have flagged the exe as suspicious. Much safer to create your own exe or self host the browser sub process using https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Core/BrowserSubprocess/SelfHost.cs#L22 Same code can be used to create own exe. |
Good to know, thanks for the heads up! |
Changes in You can override the The The interesting side-effect of this change is that it would appear that when set programmatically then the So starting in SHCore.SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.PROCESS_DPI_UNAWARE); Only seems to work when set programmatically. If for some reason this doesn't work then There are new more detailed instructions at https://github.com/cefsharp/CefSharp/wiki/SelfHost-BrowserSubProcess |
Setting User32.SetThreadDpiAwarenessContext(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); |
FWIW, I am seeing this issue in .Net 8.0 Core Winforms on Windows 10 when the display is set to 125% (but not when set to 100%). I don't see it at all on Windows 11. The fix for me was to delete app.manifest, then recreate it in Visual Studio, and uncomment the
section in the new app.manifest. The manifest change suggested above in Section Winforms HI DPI does not appear to be supported in Core Winforms. |
To revise this statement in the context of WinForms. Setting See https://learn.microsoft.com/en-us/dotnet/desktop/winforms/wfdev-diagnostics/wfac010?view=netdesktop-8.0 for Microsoft guidance regarding the compiler warning that will be raised. Starting in Application.SetHighDpiMode(HighDpiMode.DpiUnaware);
Application.SetHighDpiMode(HighDpiMode.DpiUnawareGdiScaled);
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.SetHighDpiMode(HighDpiMode.PerMonitor);
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); |
I was just hunting down down the compiler warning when I saw your post. Adding |
Currently the default
DPI Awareness
istrue/PM
, this won't suite everyone.AddCefSharpSettings
option to allow for a new command line arg to be appendedChange default to
PerMonitorV2
???Both browser process and
GPU
process (Chrome
doesn't appear to worry aboutrender
processes) must have a matching awareness.app.manifest
setting takes priority overCef.EnableHighDPISupport();
Chrome
defaults toPerMonitorV2
, we currently usePerMonitor
https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
UPDATE
Chromium
now sets theDPI Awareness
toPermonitorV2
by default. You can override this viaapp.manifest
or via programmatic call. #4410The text was updated successfully, but these errors were encountered: