Hello Guest

glfwInit should check if -XstartOnFirstThread is set

  • 8 Replies
  • 3772 Views
glfwInit should check if -XstartOnFirstThread is set
« 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.

*

Kai

Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #1 on: March 31, 2016, 11:15:32 »
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:
Code: [Select]
IllegalStateException: Please run the JVM with -XstartOnFirstThread and make sure a window toolkit other than GLFW (e.g. AWT or JavaFX) is not initialized.
« Last Edit: March 31, 2016, 11:30:36 by Kai »

Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #2 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.

*

Kai

Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #3 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"

Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #4 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.


*

Offline spasi

  • *****
  • 2123
    • WebHotelier
Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #5 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?

Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #6 on: March 31, 2016, 15:01:26 »
actually correct, it's not glfwInit(), but glfwCreateWindow()

*

Offline spasi

  • *****
  • 2123
    • WebHotelier
Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #7 on: March 31, 2016, 20:13:53 »
Thanks, fixed in nightly build #63.

Re: glfwInit should check if -XstartOnFirstThread is set
« Reply #8 on: April 01, 2016, 05:38:30 »
Thank you - works as expected now.