Page 1 of 1

SOLVED:Unable to lock surface

PostPosted: Thu Aug 19, 2021 12:44 pm
by JCEFBeginner
Hello,
when I start my application with JCEF then I get the following stack trace:
Code: Select all
Exception in thread "AWT-EventQueue-0" com.jogamp.nativewindow.NativeWindowException: Unable to lock surface
   at jogamp.nativewindow.jawt.x11.X11JAWTWindow.lockSurfaceImpl(X11JAWTWindow.java:84)
   at com.jogamp.nativewindow.awt.JAWTWindow.lockSurface(JAWTWindow.java:677)
   at com.jogamp.opengl.awt.GLCanvas.createJAWTDrawableAndContext(GLCanvas.java:718)
   at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:621)
   at org.cef.browser.CefBrowserOsr$1.addNotify(CefBrowserOsr.java:194)
   at java.awt.Container.addNotify(Container.java:2776)
   at javax.swing.JComponent.addNotify(JComponent.java:4740)
   at java.awt.Container.addNotify(Container.java:2776)
   at javax.swing.JComponent.addNotify(JComponent.java:4740)
   at java.awt.Container.addNotify(Container.java:2776)
   at javax.swing.JComponent.addNotify(JComponent.java:4740)
   at java.awt.Container.addNotify(Container.java:2776)
   at javax.swing.JComponent.addNotify(JComponent.java:4740)
   at javax.swing.JRootPane.addNotify(JRootPane.java:757)
   at java.awt.Container.addNotify(Container.java:2776)
   at java.awt.Window.addNotify(Window.java:770)
   at java.awt.Frame.addNotify(Frame.java:487)
   at java.awt.Window.pack(Window.java:807)
        [...]

I also tried to reproduce it with the JCEF test applications, but I couldn't reproduce it.

JCEFBeginner

Re: Unable to lock surface

PostPosted: Thu Aug 19, 2021 12:57 pm
by magreenblatt
Compare your code to the sample applications. Are you calling CefApp.startup?

Re: Unable to lock surface

PostPosted: Sun Aug 22, 2021 8:41 am
by JCEFBeginner
I created a simple application with JCEF for test purposes:

Code: Select all
import org.cef.CefApp;
import org.cef.CefClient;
import org.cef.CefSettings;
import org.cef.browser.CefBrowser;

import javax.swing.*;
import java.awt.*;

class CefTest {
    public static void main(String[] args) {
        CefApp.startup(args);
        CefSettings settings = new CefSettings();
        settings.windowless_rendering_enabled = true;
        CefApp app = CefApp.getInstance(settings);
        CefClient client = app.createClient();
        CefBrowser browser = client.createBrowser("www.google.de", true, false);
        Component browserUI = browser.getUIComponent();

        JFrame frame = new JFrame();
        frame.add(browserUI);
        frame.setVisible(true);

    }
}


As soon as the frame is set to visible, the exception is thrown.
Another thing that is to say is that this problem only persists on Linux, not on Windows. (I don't know how it is on Mac)

Re: Unable to lock surface

PostPosted: Thu Aug 26, 2021 12:47 pm
by JCEFBeginner
I got my simple application from my last post to work, by putting the initialization of the JFrame before "CefApp.startup(args)".
But my other application is still not working.
EDIT: My application is now working. Thank you, for your answer