Search code examples
javaswingintellij-pluginjxbrowser

JxBrowser with Java Swing (IntelliJ plugin) - "Received signal 10 BUS_ADRERR"


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.


Solution

  • 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().