App slow to close when using RegisterJsObject in version >=43
Hi, after upgrade cefsharp to 43 (winforms) and I have a problem with closing my program. It takes about 10 seconds. The problem is with RegisterJsObject. I have no idea, why it is happening, but when I delete the line with RegisterJsObject, everything is fine. It does not matter, if website contain function or not. After first load of website, the program has problem with closing.
But I can not reproduce this fault on your minimal example. Any idea where could be the problem?
chromeBrowser = new ChromiumWebBrowser(String.Empty);
chromeBrowser.RegisterJsObject("jscall", this, false);
Hi, can you check my simple application ? https://github.com/MartySVK/TestCefSharpJS
The sample I provided was for a close button handler, try removing your closing handler altogether. You may need to move your Initialize code into program main.
https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.WinForms/Program.cs#L15
I'm not near Visual Studio at the moment, so will test it later :+1:
Removing the Dispose/Shutdown calls and letting the framework handle them seems to be working in your very simple demo.
https://github.com/amaitland/TestCefSharpJS/commit/e6adb8dddc2921fc121fbf2449ff52c927ff4db4
Hi, when I remove Dispose/Shutdown, it is working, but is it safe to calling Initialize and not Shutdown ?
it is working, but is it safe to calling Initialize and not Shutdown ?
CEF requires that you call Shutdown, and for that reason CefSharp will by default call Shutdown for you.
https://github.com/cefsharp/CefSharp/blob/master/CefSharp.WinForms/ChromiumWebBrowser.cs#L76 https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Core/Cef.h#L208
For most cases this is hopefully a functional workaround. At some stage someone will need to investigate the problem further.
I've added the option to specify the Timeout to master
https://github.com/cefsharp/CefSharp/commit/d1ba723bd51c01a926a5fa6209de9358734f795e
Still just a workaround for the underlying problem.
i add this before form.close(), works for me form.Controls.Remove(browser);
I've just experienced the same problem with v49.0.1. @culmencasa 's Workaround with removing the control in my Form_Close handler fixes this issue.
I've seen this issue appear in our project since release v49.
am able to workaround using below code in the formclose handler.
CefSharpSettings.WcfTimeout = new TimeSpan(0);
Browser.Dispose();
Application.DoEvents();
CefSharpSettings.WcfTimeout = new TimeSpan(0,0,0,10);
not sure if that is how the timeout what intended to be used.. What is Wcf used for, Communication with JS?
@dandotevans Simple set WcfTimeout to Zero early on in your app would be sufficient. No need to reset.
What is Wcf used for, Communication with JS?
Javascript Binding uses WCF for communication. Switch to the async version and it will only use the native IPC (and is faster).
Small hack (only winforms):
Browser.Parent.Dispose();
Cef.Shutdown();
CefSharpSettings.WcfEnabled = false;
Cef.Shutdown();
CefSharpSettings.WcfEnabled = false;
Setting WcfEnabled to false before calling Shutdown may lead to an undesired result so beware. https://github.com/cefsharp/CefSharp/blob/11dee93bf331f012dd6416fb2f2162549d9137a3/CefSharp.Core/ManagedCefBrowserAdapter.h#L90
Closing as I've not seen reports of this in quite some time. Anyone experiencing this problem should set
CefSharpSettings.WcfTimeout = new TimeSpan(0);
Before you create the first ChromiumWebBrowser instance. The WCF channel will be aborted and won't wait for close.