-
-
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
OffScreen - Browser fails to complete loading when CEF is initialized shortly before the browser is created #3850
Comments
How are you reproducing this with WinForms exactly? Calling CreateControl immediately? |
I just mention WinForms because I've also randomly seen my winforms browser get on this "weird" never-completed-loading state, and also confirmed it by logging |
Have you confirmed the root cause is the same? |
Fundamentally CEF should support this use case, as internally it should already wait for the context to be ready. https://github.com/chromiumembedded/cef/blob/4606/libcef/browser/browser_host_create.cc#L90 It might be possible to implement some sort of workaround, the issue likely needs to be reported upstream. |
starting with 94.4.20 there are loading issues also in CefSharp.Wpf and Wpf.NETCore
|
Yes pretty sure. Here is a new test I did on the usual server (Windows Server 2016 + 4GM ram).
public partial class Form1 : Form
{
private CefSharp.WinForms.ChromiumWebBrowser Browser;
public Form1()
{
InitializeComponent();
}
private async void Form1_Load(object sender, EventArgs e)
{
CefSharp.Cef.Initialize(new CefSharp.WinForms.CefSettings() { LogSeverity = CefSharp.LogSeverity.Verbose });
//await Task.Delay(5000);
Browser = new CefSharp.WinForms.ChromiumWebBrowser("https://www.google.com");
Browser.LoadingStateChanged += Browser_LoadingStateChanged;
Browser.Dock = DockStyle.Fill;
Controls.Add(Browser);
}
private void Browser_LoadingStateChanged(object sender, CefSharp.LoadingStateChangedEventArgs e)
{
System.Diagnostics.Debug.WriteLine($"LoadingStateChanged: {e.IsLoading}");
}
} Running it will often, but not always, result in
And here is the log after uncommenting the delay:
|
@SchreinerK Please confirm if the issue reproduces with
Did You check the log file? |
@jsoldi Thanks. The fact that it only happens with limited resources will make this difficult to debug. Does calling Cef.Initialize in the programs main entry point resolve the issue? |
It doesn't. I moved the initialization to the very first line of static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
CefSharp.Cef.Initialize(new CefSharp.WinForms.CefSettings() { LogSeverity = CefSharp.LogSeverity.Verbose });
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
} |
- GlobalContextInitialized wraps a TaskCompletionSource which is resolved when the Global CefRequestContext has been created - Reduce code duplication If successful we can apply the same changes to WinForms/WPF though they're less likely to have issues than the OffScreen implementation as the CreateBrowser doesn't happen until much later Issue #3850 #3634
- GlobalContextInitialized wraps a TaskCompletionSource which is resolved when the Global CefRequestContext has been created - Reduce code duplication If successful we can apply the same changes to WinForms/WPF though they're less likely to have issues than the OffScreen implementation as the CreateBrowser doesn't happen until much later Issue #3850 #3634
There are changes to the Commit 482b423 changes the behaviour to enqueue browser creation until the
You can use the new The var t = CefSharp.Cef.InitializeAsync(new CefSharp.WinForms.CefSettings() { LogSeverity = CefSharp.LogSeverity.Verbose });
t.Wait(); |
@SchreinerK Looking at your example and I don't believe it's related to this particular issue. If I understand @jsoldi correctly then the browser will never actually be created, no amount of delay before setting the |
The changes have been in the I've not been able to reproduce the issue in Closing now. Can be reopened if further code changes are required. |
Bug Report
What version of the product are you using?
What architecture x86 or x64?
Both x86 and x64
What version of .Net?
.Net 4.6.2
On what operating system?
Windows Server 2016 or Win 10
Are you using
WinForms
,WPF
orOffScreen
?OffScreen but the error also occurs on WinForms
What steps will reproduce the problem?
I can reliable reproduce the error in a fresh Windows Server 2016 with 4GB ram. I can't reproduce it on a larger machine, so you may only get the test to fail in a 4GB ram or less machine. The steps to reproduce are:
CefSharp.Test\OffScreen
folder:FinishesLoading
test.Note that this test class doesn't use
CefSharpFixture
becauseCefSharpFixture
initializes CEF before running any test, and in order for the test to fail, the delay between CEF initialization and the first browser load must be as short as possible. This test won't shutdown CEF because the thread in which it initializes it is a different one than the one at the end of theFinishesLoading
function.If the two commented out lines are uncommented, the test passes.
What is the expected output? What do you see instead?
The test should pass.
Please provide any additional information below.
When the browser fails to complete loading, it also becomes unusable. If I open DevTools, the console cannot run any scripts. It seems to be waiting for load to complete. I also set log-severity to verbose and I don't see any errors or warning, just some component initialization log entries.
The text was updated successfully, but these errors were encountered: