2

I'm writing an IntelliJ plugin, and attempting to integrate JxBrowser into the plugin's tool window via Java Swing.

I'm using the toolWindow extension to keep the tool window integration simple.

plugin.xml

  <extensions defaultExtensionNs="com.intellij">
    <toolWindow id="pluginid" anchor="right" factoryClass="com.solutionloft.codeclippy.MainWindowFactory" />
  </extensions>

And so my main factory class looks like this:

public class MainWindowFactory implements ToolWindowFactory {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);
        Content content = toolWindow.getContentManager().getFactory().createContent(view, "", false);
        toolWindow.getContentManager().addContent(content);

        browser.loadHTML("<html><body><h1>Hello World!</h1></body></html>");
    }
}

This appears to work when I run the plugin locally initially (the tool window comes up, and I can see Hello World), but if I terminate the process and then try to run it again, I run into this error:

Received signal 10 BUS_ADRERR 000103bc3000
 [0x00017cd9540c]
 [0x00017cd95301]
 [0x7fff572eef5a]
 [0x7fbe7e9f5000]
[end of stack trace]

Process finished with exit code 138 (interrupted by signal 10: SIGBUS)

Am I missing some kind of cleanup step? I'm not sure what could still be running - the only workaround I've found at this point is to do a full computer restart, so I guess some process must be still running that's causing it to conflict. What's the proper way to clean up? Does it have anything to do with browser.dispose()? I haven't had much luck finding documentation on when .dispose() would be appropriate / if it's needed.

I'm using:
* macOS High Sierra
* Java 1.8.0_151 as my JDK
* PyCharm Ultimate as my JRE

Thanks!

Update: Noticed if I kill this process /System/Library/Frameworks/LocalAuthentication.framework/Support/coreauthd, the problem goes away for the next few runs. But sometimes this process doesn't exist and killing a still-running java process is the fix... odd.

Tadas Antanavicius
  • 4,882
  • 1
  • 20
  • 20

2 Answers2

3

According to TeamDev support, the solution is to set the system property jxbrowser.ipc.external=true. Calling System.setProperty("jxbrowser.ipc.external", "true") before you create your browser instance should do the trick. The catch is that the JxBrowser will run in lightweight mode.

You may also ensure that you're properly disposing all browser instances via browser.dispose() and the Chromium engine via BrowserCore.shutdown().

0

According to the article, all browser instances should disposed when you don't need them. Please try disposing all browser instances before closing your application.

Community
  • 1
  • 1
Nikita Shvinagir
  • 438
  • 3
  • 10
  • I'll look deeper into the proper way to do this with Swing/IntelliJ IDEA, but it seems like that may be insufficient. What if the application closes ungracefully? Or what if the user wants to run two separate instances of the application? Seems like either of those situations wouldn't be fixed by some kind of shutdown hook disposal. – Tadas Antanavicius Dec 05 '17 at 14:44
  • JxBrowser library does have the shutdown hook functionality to stop all browser instances correctly on application termination. Could you please check if there are any browser-core processes in the process manager after you terminate the process? – Nikita Shvinagir Dec 05 '17 at 17:49
  • As in, a process on my system with the name browser-core? No results for `ps -A | grep browser-core` even while the application is running. – Tadas Antanavicius Dec 05 '17 at 18:13
  • I'm sorry for the misleading. Please try checking the process with the name containin "browsercore" or "browser" after you terminate the process and when you observe mentioned issue. – Nikita Shvinagir Dec 07 '17 at 09:31