CEF seems to lock up?

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

CEF seems to lock up?

Postby jgcodes » Mon Jun 22, 2020 9:52 pm

https://github.com/jgcodes2020/JChrome

When I run the program, JCEF loads the page I coded it to. However, the program seems to not respond to input. I can't interact with JCEF or the Swing controls. What causes this and how can I fix it?
jgcodes
Techie
 
Posts: 11
Joined: Fri Jun 05, 2020 10:16 am

Re: CEF seems to lock up?

Postby magreenblatt » Mon Jun 22, 2020 10:16 pm

The linked repository is empty.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CEF seems to lock up?

Postby jgcodes » Tue Jun 23, 2020 11:26 am

The repo is set up now.
jgcodes
Techie
 
Posts: 11
Joined: Fri Jun 05, 2020 10:16 am

Re: CEF seems to lock up?

Postby magreenblatt » Tue Jun 23, 2020 11:28 am

Does the problem reproduce with the JCEF sample apps? If not, how does your app differ from the sample apps?
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CEF seems to lock up?

Postby jgcodes » Tue Jun 23, 2020 12:46 pm

It doesn't reproduce with the detailed sample.

In my app:
If I remove the Swing UI, it's fine. It locks up if I use Swing Components. I can't drag the window, click the buttons, or use the browser.
jgcodes
Techie
 
Posts: 11
Joined: Fri Jun 05, 2020 10:16 am

Re: CEF seems to lock up?

Postby magreenblatt » Tue Jun 23, 2020 1:04 pm

The sample apps also use Swing. I suggest that you start with a sample app and try adding the functionality that you need, noting at what point you start having problems.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CEF seems to lock up?

Postby jgcodes » Tue Jun 23, 2020 4:06 pm

Apparently, this seems to lock up as well. There are no calls to the look and feel library or anything outside JCEF.
Code: Select all
public class JCLauncher {
  public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
      JCFrame jcFrame = new JCFrame("www.google.ca");
    });
  }
}

Code: Select all
public class JCFrame extends JFrame {
  CefClient client; CefBrowser browser;
  public JCFrame(String url) {
    CefApp cef = CefApp.getInstance();
    client = cef.createClient();
    browser = client.createBrowser(url, false, false);

    this.add(browser.getUIComponent(), BorderLayout.CENTER);

    this.setSize(800, 600);
    this.setVisible(true);

    this.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        JCFrame.this.dispose();
        CefApp.getInstance().dispose();
      }
    });
  }
}
jgcodes
Techie
 
Posts: 11
Joined: Fri Jun 05, 2020 10:16 am

Re: CEF seems to lock up?

Postby magreenblatt » Tue Jun 23, 2020 5:19 pm

What OS, CEF and JVM version? Are the browser web contents loading and displaying? Did you create the required directory structure? Are there any console messages?

You’re not calling CefApp.startup. See the minimal sample app for reference: https://bitbucket.org/chromiumembedded/ ... Frame.java
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: CEF seems to lock up?

Postby jgcodes » Tue Jun 23, 2020 6:25 pm

The browser loads and displays the webpage, however I cannot use input. I made a call to CefApp.startup() and that doesn't seem to solve the problem. I am running Windows 10 update 2004, using JCEF 81.2.24.251, with OpenJDK 14.0.1.
jgcodes
Techie
 
Posts: 11
Joined: Fri Jun 05, 2020 10:16 am

Re: CEF seems to lock up?

Postby jgcodes » Wed Jun 24, 2020 1:53 pm

I tested a reduced version of the simple sample app and it works. I think it has to do with the introduction of an AppHandler.
Here's the new JCFrame class for reference:
Code: Select all
public class JCFrame extends JFrame {
  private final CefApp cefInstance;
  CefClient client; CefBrowser browser;
  public JCFrame(String... cefArgs) {
    CefApp.addAppHandler(new CefAppHandlerAdapter(null) {
      @Override
      public void stateHasChanged(CefApp.CefAppState state) {
        if (state == CefApp.CefAppState.TERMINATED) System.exit(0);
      }
    });

    CefSettings settings = new CefSettings();
    boolean useOSR = (Arrays.binarySearch(cefArgs, "-osr") >= 0);
    settings.windowless_rendering_enabled = useOSR;

    cefInstance = CefApp.getInstance(settings);
    client = cefInstance.createClient();

    browser = client.createBrowser("www.google.ca", useOSR, false);

    this.add(browser.getUIComponent());
    this.setVisible(true);
    this.setExtendedState(JFrame.MAXIMIZED_BOTH);

    this.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        cefInstance.dispose();
        dispose();
      }
    });
  }
}
jgcodes
Techie
 
Posts: 11
Joined: Fri Jun 05, 2020 10:16 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 11 guests