chromiumembedded / java-cef

Java Chromium Embedded Framework (JCEF). A simple framework for embedding Chromium-based browsers in other applications using the Java programming language.
https://bitbucket.org/chromiumembedded/java-cef
Other
605 stars 135 forks source link

Closing not working as expected #468

Open naniox2 opened 4 months ago

naniox2 commented 4 months ago

Describe the bug I'm having a lot of trouble closing the browser

Processes sometimes remain after closing the browser and for some reason they load the CPU by 100%

browser.close and browser.doclose do not work (do not close processes) also cefapp.dispose does not close all processes

To Reproduce

public static void main(String[] args) throws Exception {
    CefSettings settings = new CefSettings();
    settings.windowless_rendering_enabled = true;
    CefApp cefApp = CefApp.getInstance(settings);
    CefClient client = cefApp.createClient();

    for (int i = 0; i < 10; i++) {
        CefBrowser browser = client.createBrowser("https://example.com/", true, true);
        browser.createImmediately();

        Thread.sleep(5000L);
        browser.getSource(System.out::println);

        browser.close(true);
        ThreadUtil.sleep(1000L);
    }

    client.dispose();
    cefApp.dispose();

    System.exit(0);
}

Expected behavior Should close all processes using cefapp.dispose or close all browser processes and not add new ones using browser.close And don't load CPU by 100%

Screenshots image

Versions (please complete the following information):

Additional context Sometimes it closes all processes if I use 1 browser, but sometimes 1 process remains, which for some reason loads CPU by 5-20%. In the code i gave above i create and close browsers many times, but it creates new processes each time

wjw465150 commented 2 months ago

I also found this problem, calling client.dispose() did not terminate the jcef_helper process. The version I use is: OS: CentOS 7 Java Version: JDK 17.0.6 JCEF Version: jcef-api-jcef-0b8e42e CEF Version: 122.1.10+gc902316+chromium-122.0.6261.112

magreenblatt commented 2 months ago

Some helper processes are expected to remain until the application terminates. See also https://github.com/chromiumembedded/cef/issues/3614

wjw465150 commented 2 months ago

This problem is not found under windows