diff --git a/src/main/java/cpw/mods/fml/client/FMLClientHandler.java b/src/main/java/cpw/mods/fml/client/FMLClientHandler.java index 0cddcff..b87bc7e 100644 --- a/src/main/java/cpw/mods/fml/client/FMLClientHandler.java +++ b/src/main/java/cpw/mods/fml/client/FMLClientHandler.java @@ -1003,9 +1003,11 @@ public void processWindowMessages() { // workaround for windows requiring messages being processed on the main thread - if(LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS) - { - Display.processMessages(); - } + if (LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_WINDOWS) return; + // If we can't grab the mutex, the update call is blocked, probably in native code, just skip it and carry on + // We'll get another go next time + if (!SplashProgress.mutex.tryAcquire()) return; + Display.processMessages(); + SplashProgress.mutex.release(); } } \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/SplashProgress.java b/src/main/java/cpw/mods/fml/client/SplashProgress.java index ef510b2..2742384 100644 --- a/src/main/java/cpw/mods/fml/client/SplashProgress.java +++ b/src/main/java/cpw/mods/fml/client/SplashProgress.java @@ -13,6 +13,7 @@ import java.nio.IntBuffer; import java.util.Iterator; import java.util.Properties; +import java.util.concurrent.Semaphore; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -81,6 +82,7 @@ private static int barBorderColor; private static int barColor; private static int barBackgroundColor; + static final Semaphore mutex = new Semaphore(1); private static String getString(String name, String def) { @@ -297,7 +299,16 @@ glEnd(); glDisable(GL_TEXTURE_2D); + // We use mutex to indicate safely to the main thread that we're taking the display global lock + // So the main thread can skip processing messages while we're updating. + // There are system setups where this call can pause for a while, because the GL implementation + // is trying to impose a framerate or other thing is occurring. Without the mutex, the main + // thread would delay waiting for the same global display lock + mutex.acquireUninterruptibly(); Display.update(); + // As soon as we're done, we release the mutex. The other thread can now ping the processmessages + // call as often as it wants until we get get back here again + mutex.release(); if(pause) { clearGL();