Skip to content

Conversation

@cyoung06
Copy link

As far as I know, the crash is caused by two different threads accessing OpenGL context

  1. Appkit Thread -> _surfaceNeedsUpdate -> [self update;] -> [_openGLContext update];
  2. Just normal java main thread (or Minecraft client thread in my case) -> draws some stuffs

Two threads accessing same OpenGL context makes it crash.

According to https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_threading/opengl_threading.html
One solution is to use CGLLockContext and CGLUnlockContext properly, but it has to be done in both threads and it would be really hard to achieve

Or another solution is just prevent appkit thread from calling [_openGLContext update];, since LWJGL application is going to do that some time later.

This PR implements the second solution to the problem, by deleting one line from org_lwjgl_opengl_Display.m

I have tested this on Minecraft 1.8.9 on m1 arm, and it did not crash, and it didn't seem to have any side effects.

But I do consider this solution a bit hacky so it is up to you to accept this

@Moresteck
Copy link

This fix does indeed work. I've come up with a similar solution, I cleared the update function instead. But this patch seems to work the same.

I support this PR to be merged.

thecatcore added a commit to Legacy-Fabric/lwjgl that referenced this pull request May 29, 2025
thecatcore added a commit to Legacy-Fabric/lwjgl that referenced this pull request Sep 26, 2025
Taken from MinecraftMachina#3
Author: cyoung06

(cherry picked from commit edc2ac8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants