A non-headless environment is required to access the Desktop.getDesktop() API for user interaction. If java.awt.headless=false is set and AWT is initialized on macOS, the JVM hangs. AWT is accidentally initialized by OptiFine because the Mipmaps class uses java.awt.Dimension as a simple integer 2-tuple. This class has a static initializer block that runs JNI code if the environment is not headless.
Steps to Reproduce
Run OptiFine on macOS with -Djava.awt.headless=false
OptiFine Version
At least 1.16.3, probably any.
Installation Method
Shouldn't matter, but OptiFabric was used.
Logs
All the logs I've seen are normal, they just hang after logging about generating mipmaps.
This should be easily fixable by creating a custom "Dimension" class that contains width and height fields and swapping the import statement. In fact, a StackOverflow post from 2013 says exactly this: https://stackoverflow.com/a/17389889/9073728
Description of Issue
A non-headless environment is required to access the
Desktop.getDesktop()
API for user interaction. Ifjava.awt.headless=false
is set and AWT is initialized on macOS, the JVM hangs. AWT is accidentally initialized by OptiFine because the Mipmaps class usesjava.awt.Dimension
as a simple integer 2-tuple. This class has a static initializer block that runs JNI code if the environment is not headless.Steps to Reproduce
Run OptiFine on macOS with
-Djava.awt.headless=false
OptiFine Version
At least 1.16.3, probably any.
Installation Method
Shouldn't matter, but OptiFabric was used.
Logs
All the logs I've seen are normal, they just hang after logging about generating mipmaps.
Additional Information
Discovered here: https://github.com/magneticflux-/fabric-mumblelink-mod/issues/32
This should be easily fixable by creating a custom "Dimension" class that contains
width
andheight
fields and swapping the import statement. In fact, a StackOverflow post from 2013 says exactly this: https://stackoverflow.com/a/17389889/9073728