I'm using Ubuntu 20.04.5 and Java 1.8 (also tried java 16, same problem)
I'm trying to make a screenshot using JCEF and always getting a NullPointerException while invoking org.cef.browser.CefBrowserOsr::createScreenshot.
At the third line of this method (pinned below), where it's trying "get OpenGL internals" using this.canvas_.getGL().getGL2(), the ::getGL method is returning null, so the next ::getGL2 method can't be invoked.
Link to problem line: https://github.com/JetBrains/jcef/blob/ ... .java#L470
Code:
- Code: Select all
public class Test extends JFrame {
public ChromiumRenderer(String[] args) {
if (!CefApp.startup(args))
System.out.println("Startup initialization failed!");
CefSettings settings = new CefSettings();
settings.windowless_rendering_enabled = true;
CefApp app = CefApp.getInstance(args, settings);
this.browser = app.createClient().createBrowser(
"https://www.google.com",
true, false,
CefRequestContext.getGlobalContext()
);
super.getContentPane().add(this.browser.getUIComponent(), BorderLayout.CENTER);
super.pack();
super.setSize(800, 800);
super.setVisible(false);
// The problem is here
Image result = this.browser.createScreenshot(true).join();
}
}
Can anyone help me with this and explain what I'm doing wrong? It feels like I forgot to configure something.
I will be very grateful for help.