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

WinForms - Control is not Docking properly on 1st load. #3502

Closed
melegant opened this issue Apr 13, 2021 · 4 comments
Closed

WinForms - Control is not Docking properly on 1st load. #3502

melegant opened this issue Apr 13, 2021 · 4 comments

Comments

@melegant
Copy link

melegant commented Apr 13, 2021

Bug Report

Version 89.0.170.0
Nuget
architecture x86
Windows 10
WinForms

  • What steps will reproduce the problem?
    The dock property of the control is not docking the control Full inside the Tab Container until the second time we open the form.

  • What is the expected output? What do you see instead?
    1st time we open the form:
    image
    2nd time we open the form
    image
    For the rest of the session the browser control displays properly.

  • Please provide any additional information below.
    We create the instance of the control in the constructor of the form that ends up being the shown inside the tab.
    ` InitializeComponent();

          _systemSettings = ServiceLocator.Resolve<ISystemSettings>();
          _tokenService = ServiceLocator.Resolve<ITokenService>();
          _userService = ServiceLocator.Resolve<IUserService>();
    
          WindowState = FormWindowState.Maximized;
          browser = new ChromiumWebBrowser("www.google.com") { Dock = DockStyle.Fill };
          Controls.Add(browser);
    
          browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged;`
    

    `private void OnIsBrowserInitializedChanged(object sender, EventArgs e)
    {
    var b = ((ChromiumWebBrowser)sender);

          this.InvokeOnUiThreadIfRequired(() => b.Focus());
          this.InvokeOnUiThreadIfRequired(() => b.Refresh());
      }`
    

In the load of the application we are initializing settings :

 if (!Cef.IsInitialized)
                {
                    Cef.EnableHighDPISupport();
                    var settings = new CefSettings();

                    Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
                }

NOTE - We discovered that be putting this in app manifest it fixes this issue but breaks the rest of the application :)

<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</ms_windowsSettings:dpiAware> </asmv3:windowsSettings>

Thanks for the help.

@melegant
Copy link
Author

Untitled_.Apr.13.2021.3_39.PM.mp4

Attached a movie of what is happening.

@amaitland
Copy link
Member

This is a limitation of chromium,
https://github.com/cefsharp/CefSharp/wiki/General-Usage#high-dpi-additional-info has details about a workaround.

Issue #2927 already tracks adding additional options.

@amaitland amaitland changed the title Control is not Docking properly on 1st load. WinForms - Control is not Docking properly on 1st load. Apr 13, 2021
@melegant
Copy link
Author

@amaitland Hi that did that trick.
We put this in the settings and now it works.
settings.CefCommandLineArgs.Add("disable-gpu", "1");

@amaitland
Copy link
Member

Disabling only GPU compositing is preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants