LWJGL Forum

Programming => Bug Reports / RFE => Topic started by: arisona on March 31, 2016, 10:14:01

Title: glfwInit should check if -XstartOnFirstThread is set
Post by: arisona on March 31, 2016, 10:14:01
currently, glfwInit crashes natively if -XstartOnFirstThread. it would be nice if one could catch this more gracefully e.g. by checking if -XstartOnFirstThread is set (similarly to glfwCreateWindow), and throwing an exception if not.
Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: Kai on March 31, 2016, 11:15:32
Quote from: arisona on March 31, 2016, 10:14:01
currently, glfwInit crashes natively if -XstartOnFirstThread.
Really? That's very odd, because on OS X you are required to use -XstartOnFirstThread, otherwise LWJGL would complain with a:

IllegalStateException: Please run the JVM with -XstartOnFirstThread and make sure a window toolkit other than GLFW (e.g. AWT or JavaFX) is not initialized.
Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: arisona on March 31, 2016, 11:36:13
Yes, that's how I remembered it.

Now (3.0.0-SNAPSHOT) I'm calling glwfInit() basically as the first thing in my code, and will then eventually open a window.

GLFW.glfwInit() basically is

   public static int glfwInit() {
      long __functionAddress = Functions.Init;
      return invokeI(__functionAddress);
   }

without any checks, while GLFW.createWindow does

EventLoop.OffScreen.check();

... unless I'm missing something here.
Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: Kai on March 31, 2016, 11:41:32
Ah... you mean that glfwInit() crashes if -XstartOnFirstThread is not specified as VM argument.
So your "glfwInit crashes natively if -XstartOnFirstThread.", actually means: "glfwInit crashes natively if -XstartOnFirstThread was not set/omitted as VM argument"
Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: arisona on March 31, 2016, 11:42:48
yes, sorry, my bad i should have read it again before posting

yes, it crashes if -XstartOnFirstThread is *not* set.

Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: spasi on March 31, 2016, 14:04:21
I found the problem, the thread check is effectively disabled by default. It will be fixed in the next nightly build.

I can't reproduce a crash on glfwInit though, that's why it doesn't even have the check. Are you sure it crashes for you on glfwInit and not on glfwCreateWindow?
Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: arisona on March 31, 2016, 15:01:26
actually correct, it's not glfwInit(), but glfwCreateWindow()
Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: spasi on March 31, 2016, 20:13:53
Thanks, fixed in nightly build #63.
Title: Re: glfwInit should check if -XstartOnFirstThread is set
Post by: arisona on April 01, 2016, 05:38:30
Thank you - works as expected now.