Fix fatal JVM crash on macOS during hardware instancing (LwjglGLExt ARB extensions)#2893
Open
riccardobl with Copilot wants to merge 2 commits into
Open
Fix fatal JVM crash on macOS during hardware instancing (LwjglGLExt ARB extensions)#2893riccardobl with Copilot wants to merge 2 commits into
riccardobl with Copilot wants to merge 2 commits into
Conversation
…tead of ARB extensions On macOS OpenGL Core Profile, legacy ARB extension pointers are stripped even when the same functionality is available via core entry points. This caused a JVM crash when attempting hardware instancing because LwjglGLExt was calling ARBDrawInstanced/ARBInstancedArrays functions that don't exist in the Core Profile. Each method now prefers the equivalent core GL function (promoted to core in the GL version noted in the comment) and falls back to the corresponding ARB extension only when the core entry point is unavailable. This keeps compatibility with older GL2-era contexts that have the ARB extensions but lack the core promotion. Affected mappings: - glDrawArraysInstancedARB → GL31.glDrawArraysInstanced (core since GL3.1) - glDrawElementsInstancedARB → GL31.glDrawElementsInstanced (core since GL3.1) - glVertexAttribDivisorARB → GL33.glVertexAttribDivisor (core since GL3.3) - glGetMultisample → GL32.glGetMultisamplefv (core since GL3.2) - glTexImage2DMultisample → GL32.glTexImage2DMultisample (core since GL3.2) - glGetUniformBlockIndex → GL31.glGetUniformBlockIndex (core since GL3.1) - glBindBufferBase → GL30.glBindBufferBase (core since GL3.0) - glUniformBlockBinding → GL31.glUniformBlockBinding (core since GL3.1) - glGetProgramResourceIndex → GL43.glGetProgramResourceIndex (core since GL4.3) - glShaderStorageBlockBinding→ GL43.glShaderStorageBlockBinding (core since GL4.3) - glFenceSync → GL32.glFenceSync (core since GL3.2) - glClientWaitSync → GL32.glClientWaitSync (core since GL3.2) - glDeleteSync → GL32.glDeleteSync (core since GL3.2) Fixes #2892
Copilot
AI
changed the title
[WIP] Fix fatal JVM crash on macOS during hardware instancing
Fix fatal JVM crash on macOS during hardware instancing (LwjglGLExt ARB extensions)
Jul 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the LWJGL3 GLExt implementation to avoid native JVM crashes on macOS Core Profile by preferring core OpenGL entry points (when available) instead of dispatching through legacy ARB extension function pointers that may be stripped by the driver.
Changes:
- Switch instancing calls (
glDraw*Instanced*,glVertexAttribDivisor*) to dispatch to core GL methods when the corresponding core version is available, otherwise fall back to ARB extensions. - Apply the same core-preferred dispatch pattern to multisample texture functions, UBO-related functions, sync objects, and several newer-program-interface/SSBO-related functions.
- Improve class-level Javadoc (including a typo fix and explanation of the macOS Core Profile issue).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS, OpenGL Core Profile drivers strip legacy ARB extension function pointers even when equivalent functionality is available via core entry points.
LwjglGLExtwas unconditionally dispatching through ARB (e.g.ARBDrawInstanced.glDrawArraysInstancedARB), causing an immediate fatal native crash on any instanced draw call.Changes
jme3-lwjgl3/LwjglGLExt.java: Each method now queriesGL.getCapabilities()at runtime and dispatches to the core GL entry point when available, falling back to the ARB extension only for older contexts (e.g. GL 2.0 + ARB extensions) that predate the core promotion.glDrawArraysInstancedARBGL31.glDrawArraysInstancedARBDrawInstancedglDrawElementsInstancedARBGL31.glDrawElementsInstancedARBDrawInstancedglVertexAttribDivisorARBGL33.glVertexAttribDivisorARBInstancedArraysglGetMultisample/glTexImage2DMultisampleGL32.*ARBTextureMultisampleGL30/GL31.*ARBUniformBufferObjectGL32.*ARBSyncGL43.*ARBShaderStorageBufferObject/ARBProgramInterfaceQueryExample dispatch pattern applied throughout: