Closed ohlookitsben closed 2 years ago
Thanks for the detailed bug report 👍
If you add a border around the ChromiumWebBrowser
instance does it fill the entire Form
when the control renders incorrectly? If yes then it's probably a timing issue when the internal CefBrowser
has it's width/height
set.
Apologies for the delay in response. I haven't easily been able to capture an image of the control with a border around it - the incidence of this failure on my test application has really dropped off lately and I'm not sure why. I've captured a video of the failure in our actual application that might answer some questions around how the control is being laid out.
A few observations
I've captured a video of the failure in our actual application that might answer some questions around how the control is being laid out.
If you can reliably reproduce the problem in your application then you can do some debugging. CefSharp
is built with GitLink, there are instructions on the GitLink
site about how to enable within Visual Studio
. You can step into ChromiumWebBrowser
and add some breakpoints to the following:
The video doesn't really tell me anything meaningful.
I just ran your example three times (total of 150 browsers created) and I've yet to see the problem reproduce.
Does the problem reproduce on multiple machines with different hardware/software configurations or is it limited to a single hardware/software config?
The problem is reproducible on a few different machine configurations. We've had 2 or 3 clients report this issue that would be using different machines to us. The machines we're using for development also display these issues. The models we know of that can reproduce this are Dell Precision 5530, Dell Precision M4800, Panasonic Toughbook FZ-G1, Dell Precision 7530. The issue has been long-standing for us, and we have records of it back to CEF 65.0, so I don't think this is likely to be a recently introduced thing.
If you can reproduce the problem on a machine with visual studio installed you should fairly easily be able to debug this. If the ChromiumWebBrowser instance fills the space correctly then it's likely something related to the internal ResizeBrowser calls.
Still in the process of digging into this:
ChromiumWebBrowser
and the ManagedCefBrowserAdapter
and am still able to reproduce, so I don't think it's caused by running any code inside these handlers at this stage. Let me know if you want this provided as a fork, should be easy to push up if it's more useful than the minimal test app I had.WindowInfo
passed in here and it's consistently 0,0 even when the issue occurs (though setting it to some negative value in a debugger reproduces the symptoms of the issue).Has there been any resolution on this issue?
I'm seeing the behaviour consistently here.
I create a simple Form with a panel. I add the Cef control to the panel. The contents are misaligned and offset (down and to the right). I've tried several small sample apps I found on the web. I've tried previously releases of the Cef library. I see the same results every time.
I've attached a zip of my project here.
Can anyone shine any light on this? Until I can get this resolved the control will be unusable for us.
Thanks CefTest.zip
After much googling, I found a solution that worked for me. The issue appears to be DPI related.
I added this to my winforms App.config file:
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAware" value="true"/>
<add key="DpiAwareness" value="PerMonitorV2"/>
</System.Windows.Forms.ApplicationConfigurationSection>
I also set my .Net Framework version to be 4.7.2 (anything prior to that causes the same issue).
With the combination of these changes, the Cef browser control aligns correctly in it's parent container.
Hope this helps someone else.
The issue appears to be DPI related.
See https://github.com/cefsharp/CefSharp/wiki/General-Usage#high-dpi-displayssupport for information regarding DPI.
This particular issue isn't related to DPI.
I'm going to close this issue for now as I've not seen any further reports and I've never been able to reproduce the issue myself so this isn't something I can debug.
Based on the described behaviour it's entirely possible it's a problem deep within Chromium
that only reproduces with a set GPU
.
What version of the product are you using? package id="CefSharp.WinForms" version="90.6.70" targetFramework="net472"
What architecture x86 or x64? x64
What version of .Net? .Net 4.7.2
On what operating system? Win10
Are you using
WinForms
,WPF
orOffScreen
? WinFormsWhat steps will reproduce the problem?
The issue is not reproducible in the example code as there are no dialogs launched in this way.
What is the expected output? What do you see instead? I expect the contents of the CEF browser window to render inside the form that contains the browser control with correct alignment.
The contents are instead misaligned relative to the window containing the browser control. This is visible in the video of the issue at 0:51.
Please provide any additional information below. I have attached a sample application that reproduces this issue. This is the application used in the video linked previously. CefFormStartPosition.zip https://github.com/ohlookitsben/cefformstartposition
The commented line in this file appears to be the trigger for this bug. Removing it will cause the browser to position correctly. https://github.com/ohlookitsben/cefformstartposition/blob/main/CefFormStartPosition/BrowserDialog.cs
This may be possible to reproduce without resizing the main form, but I'm yet to see it. This issue does not seem to appear if the parent form is the same size as the dialog.
Setting FormStartPosition to CenterScreen also produces the same issue
Does this problem also occur in the
CEF
Sample Application The sample applications do not open dialogs so the issue cannot be reproduced.