Fix crash on macos when resizing windows #3
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.
As far as I know, the crash is caused by two different threads accessing OpenGL context
_surfaceNeedsUpdate->[self update;]->[_openGLContext update];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