java-cef icon indicating copy to clipboard operation
java-cef copied to clipboard

java.lang.ArrayIndexOutOfBoundsException when running on OpenJDK 16-ea

Open magreenblatt opened this issue 4 years ago • 4 comments

Original report by Antony Helliwell (Bitbucket: Antony Helliwell).


Summary: Attempting to create a browser with --offscreen-rendering-enabled throws java.lang.ArrayIndexOutOfBoundsException when running on OpenJDK 16-ea and Windows

Steps to reproduce: Using OpenJDK 16-ea on Windows build and JCEF from commit 0e666a6d6c52dc1478ccf59167f96ad45e53d4b5 (bb) execute the detailed sample application as follows:

java -cp "./bin;./bin/*" -Djava.library.path=./bin/lib/win64 tests.detailed.MainFrame --off-screen-rendering-enabled

Expected result: Should display browser

Actual result: Java traceback, no browser is displayed. The following information is output:

Offscreen rendering enabled
Option --off-screen-rendering-enabled
Using:
JCEF Version = 87.1.12.275
CEF Version = 87.1.12
Chromium Version = 87.0.4280.88
AppHandler.stateHasChanged: INITIALIZING
initialize on Thread[AWT-EventQueue-0,6,main] with library path ./bin/lib/win64
Added scheme search://
Added scheme client://
AppHandler.stateHasChanged: INITIALIZED
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1
at jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171)
at com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
at com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1513)
at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:609)
at org.cef.browser.CefBrowserOsr$1.addNotify(CefBrowserOsr.java:185)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/javax.swing.JRootPane.addNotify(JRootPane.java:729)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/java.awt.Window.addNotify(Window.java:787)
at java.desktop/java.awt.Frame.addNotify(Frame.java:493)
at java.desktop/java.awt.Window.show(Window.java:1049)
at java.desktop/java.awt.Component.show(Component.java:1720)
at java.desktop/java.awt.Component.setVisible(Component.java:1667)
at java.desktop/java.awt.Window.setVisible(Window.java:1032)
at tests.detailed.MainFrame.main(MainFrame.java:79)

The problem does not occur on OpenJDK 15

It would appear jogl 2.4.0 included in JCEF does not include the following commit: https://github.com/sgothel/jogl/commit/d335d99df25cc929d06765c3f1af3944f124f6a7 - the code path appears to be executed on OpenJDK 16-ea, but not earlier versions of the OpenJDK

magreenblatt avatar Feb 10 '21 14:02 magreenblatt

Original comment by Antony Helliwell (Bitbucket: Antony Helliwell).


Replacing the jogl library with version v2.4.0-rc-20210111 avoids the ArrayIndexOutOfBoundsException, but now reports on OpenJDK-16

Exception in thread "main" com.jogamp.opengl.GLException: Unable to determine GraphicsConfiguration: WindowsWGLGraphicsConfiguration[DefaultGraphicsScreen[WindowsGraphicsDevice[type .windows, connection decon, unitID 0, handle 0x0, owner false, NullToolkitLock[obj 0x5663f46f]], idx 0], pfdID 9, ARB-Choosen true,
requested GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]],
chosen GLCaps[wgl vid 9 arb: rgba 8/8/8/0, opaque, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]]]
at jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:182)
at com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
at com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1513)
at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:609)
at org.cef.browser.CefBrowserOsr$1.addNotify(CefBrowserOsr.java:194)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4792)
at java.desktop/javax.swing.JRootPane.addNotify(JRootPane.java:729)
at java.desktop/java.awt.Container.addNotify(Container.java:2801)
at java.desktop/java.awt.Window.addNotify(Window.java:787)
at java.desktop/java.awt.Frame.addNotify(Frame.java:493)
at java.desktop/java.awt.Window.show(Window.java:1049)
at java.desktop/java.awt.Component.show(Component.java:1720)
at java.desktop/java.awt.Component.setVisible(Component.java:1667)
at java.desktop/java.awt.Window.setVisible(Window.java:1032)
at tests.detailed.MainFrame.main(MainFrame.java:79)

magreenblatt avatar Mar 09 '21 17:03 magreenblatt

Original comment by Antony Helliwell (Bitbucket: Antony Helliwell).


The issue appears to be in the com.jogamp.common.util.UnsafeUtil class and results from changing the default value of the launcher option --illegal-access to deny rather than permit

Adding --illegal-access=permit to the command line fixes the issue

magreenblatt avatar Mar 11 '21 08:03 magreenblatt

Original comment by Antony Helliwell (Bitbucket: Antony Helliwell).


Running on OpenJDK 17-ea the workaround above, adding --illegal-access=permit no longer works - the option has been disabled. Off-screen rendering in JCEF doesn’t appear to be possible at all on Windows using JDK-17 without changes to the underlying jogamp libraries

magreenblatt avatar Jun 14 '21 10:06 magreenblatt

Original comment by FriwiDev (Bitbucket: Fritz Windisch).


To use jogl on jdk 17 (osr mode in jcef), one must add these arguments:

--add-exports java.base/java.lang=ALL-UNNAMED
--add-exports java.desktop/sun.awt=ALL-UNNAMED
--add-exports java.desktop/sun.java2d=ALL-UNNAMED

As mentioned here: https://jogamp.org/bugzilla/show_bug.cgi?id=1317#c21

See more details on java 17 and jcef here: https://github.com/jcefmaven/jcefmaven/issues/45

magreenblatt avatar Apr 01 '22 10:04 magreenblatt