我正在尝试使JCEF在简单的JavaFX应用程序的swingNode
中工作
public class MainApp extends Application {
@Override
public void start(Stage stage) throws Exception {
SwingNode swingNode = new SwingNode();
SwingUtilities.invokeAndWait(() -> {
String startURL = "https://www.google.com/";
boolean useOSR = OS.isLinux();
boolean isTransparent = false;
CefSettings settings = new CefSettings();
settings.windowless_rendering_enabled = useOSR;
CefApp cefApp_ = CefApp.getInstance(settings);
CefClient client_ = cefApp_.createClient();
CefBrowser browser_ = client_.createBrowser(startURL, useOSR, isTransparent);
Component browerUI_ = browser_.getUIComponent();
JPanel panel = new JPanel();
panel.setSize(800, 600);
panel.add(browerUI_, BorderLayout.CENTER);
swingNode.setContent(panel);
});
stage.setScene(new Scene(new javafx.scene.Group(swingNode)));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
我在
client_.createBrowser(startURL, useOSR, isTransparent);
遇到致命错误initialize on Thread[AWT-EventQueue-0,6,main] with library path /path/to/jcef/lib/linux64
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f3d07fced50, pid=22843, tid=0x00007f3ca5991700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [ld-linux-x86-64.so.2+0x9d50]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /path/to/jcef-javafx-maven/hs_err_pid22843.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
但是,提供的JCEF awt测试示例可以完美运行。
JCEF Version = 3.2840.147
CEF Version = 3.2840.1511
Chromium Version = 54.0.2840.59
Oracle JDK version = 1.8.0_111
edit1:深入研究jcef Java代码,致命错误发生在
CefBrowserOsr.java
第134行private void createGLCanvas() {
GLProfile glprofile = GLProfile.getMaxFixedFunc(true); // here
edit2:错误日志
hs_err_pid.log
content。 最佳答案
升级到JOGL 2.3.2并再次重建JCEF可以部分解决问题(不再发生jvm崩溃)
但是,SwingNode
似乎不会呈现诸如GLCanvas
,reference之类的非常复杂的内容。