JCEF in IntelliJ plugins (Linux issue)

Answered

I've found a few posts with others trying to embed JCEF in IntelliJ:

 - https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000118404-Toolwindow-plugin-with-JCEF-is-not-repainted-when-switching-back-from-other-toolwindows

 - https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000655199-Creating-JAR-with-dependencies-Jars-and-Dlls-

 - https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003414259-Tool-window-with-embedded-java-cef

None of these seem to help with the problem I'm facing but the last post looks pretty hopeful.

 

I'm not exactly sure what kind of issue I'm facing but essentially I'm trying to embed JCEF in an IntelliJ plugin and it doesn't seem to paint the component. It remains empty as if it was hanging. The last post I linked above includes this image (https://gifyu.com/image/3BLt) where OP points out that browser.canvas shows invalid. I thought that was what I was dealing with but even running JCEF outside of IntelliJ it shows up the same. It seems OP was able to solve their problem using ContentFactory but my main application isn't dealing with ToolWindows. My main plugin is trying to embed a browser in the IntelliJ Balloon components and this test plugin is just trying to bring up a JFrame. I know this can work because I've been evaluating this approach with JxBrowser and it also relies on Chromium.

 

Plugin to demonstrate the issue: https://github.com/BFergerson/jcef-intellij-plugin-test

@Override
public void runActivity(@NotNull Project project) {
showBrowser();
}

private static void showBrowser() {
try {
JourneyLoader.setup();
} catch (Exception e) {
throw new RuntimeException(e);
}

CefApp cefApp = CefApp.getInstance(JourneyBrowserView.DEFAULT_SETTINGS);
CefClient client = cefApp.createClient();
CefBrowser browser = client.createBrowser("https://google.com", false, false);
Component browserUI = browser.getUIComponent();
JFrame mainFrame = new JFrame();
mainFrame.getContentPane().add(browserUI, BorderLayout.CENTER);
mainFrame.setSize(1000, 600);
mainFrame.setVisible(true);
browser.setFocus(true);
mainFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent windowEvent) {
mainFrame.dispose();
cefApp.dispose();
}
});
}

 

When running that program via the main method, you will see this:

https://youtu.be/TmMNnEeXj64

 

When running the same code through IntelliJ, you will see this:

https://youtu.be/w8aXqkFp2k4

 

I apologize for the lack of detail. As I said, I'm not exactly sure what I'm facing here so I'm hoping an IntelliJ guru can point me in the right direction. This same code works standalone on Windows/Linux and it works in IntelliJ in Windows (after removing a call to System.loadLibrary("jawt")), but doesn't work on Linux in IntelliJ. I'm using Ubuntu 18.04.

 

5 comments
Comment actions Permalink

FYI we're currently working on JCEF-based WebView component. I'd suggest to wait for its official availability IJ platform.

1
Comment actions Permalink

Yann, it's good to hear JCEF will be supported natively soon. Do you know where I can go to track the progress of that component? If that's going to happen soon enough then I see no reason to bother you guys with the issues I'm facing with JCEF (although I'm still curious as to why JCEF won't run on its own in IntelliJ).

0
Comment actions Permalink

Please keep an eye to upcoming 2019.2 EAP, it will surely be announced as new feature during early access releases.

0
Comment actions Permalink

Hi Yann, I was looking into the EAP Users forum and issue tracker and I couldn't find any mention of JCFE yet. Do you have any news about it? Thanks!

0
Comment actions Permalink

Unfortunately, we had to shift our schedule. At the moment JCEF integration is targeting 2019.3. Please follow it on YouTrack: https://youtrack.jetbrains.com/issue/JBR-1603

0

Please sign in to leave a comment.