Java CEF doesn't shutdown

Having problems with building or using the JCEF Java binding? Ask your questions here.

Java CEF doesn't shutdown

Postby harnekmanj » Thu Jan 07, 2016 3:20 pm

OS: Windows
CEF: 3.2454.1344

I am using Java DockableFrame to display the browser window. In the case when I just create the CefClient and create the CefBrowser and do load the URL but doesn't load the dockableframe that contains the UI component of the browser I only get the single jcef_helper process in the Task manager. Now if I exit the main application the CefApp thread is not killed and due to that the main application stays running in the Task manager. But if I do load the dockableFrame that has the Browser component then I do get the 2 jcef_helper processes and when I exit the main application it gets properly shut down. So I am struggling why the 1st case is not cleaning up properly.

Following is the code to StartBrowser

private void startBrowser() {
System.out.println( "*********** Starting browser **************");
boolean useOSR = true;
boolean isTransparent = false;
CefSettings settings = new CefSettings();
settings.windowless_rendering_enabled = useOSR;
cefApp_ = CefApp.getInstance(settings);
client_ = cefApp_.createClient();

//Create the cookie manager
cookieManager_ = CefCookieManager.getGlobalManager();
//This sets up sqlite database for cookies.
cookieManager_.setStoragePath(cookiePath, true);

browser_ = client_.createBrowser(startURL_, useOSR, isTransparent);

browser_.loadURL(startURL_);
browserUI_ = browser_.getUIComponent();
add(browserUI_, BorderLayout.CENTER);
System.out.println("*************** Loaded Browser ****************");
}

Code to dispose the CefApp when main application calls exit.
CefApp.CefAppState cefAppState = CefApp.getState();
//Made this check over here so that if the CefApp is not initalized then no need to dispose.
if (cefAppState != CefApp.CefAppState.NONE && cefAppState != CefApp.CefAppState.SHUTTING_DOWN && cefAppState != CefApp.CefAppState.TERMINATED)
{
CefApp cefApp = CefApp.getInstance();
if (cefApp != null)
{
cefApp.dispose();
}
}

Please let me know what I have done wrong or what extra should I add so that the CefApp gets shutdown properly.

Any help will be appreciated and thanks in advance.
harnekmanj
Techie
 
Posts: 14
Joined: Fri Nov 27, 2015 8:23 pm

Re: Java CEF doesn't shutdown

Postby Madman101 » Tue Feb 16, 2016 5:06 pm

I solved this wrapping it in a invokeLater, eg;

Code: Select all
SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        CefApp.getInstance().dispose();
    }
});
Madman101
Newbie
 
Posts: 5
Joined: Tue Feb 16, 2016 5:03 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 21 guests