Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work on Mac #12

Open
sharhar opened this issue Jul 23, 2017 · 14 comments
Open

Does not work on Mac #12

sharhar opened this issue Jul 23, 2017 · 14 comments

Comments

@sharhar
Copy link
Collaborator

sharhar commented Jul 23, 2017

The glfwPollEvents function must be called from the main thread. (Windows should also only be created on the main thread). Since the WIndowModule class uses a thread callback to do the per frame rendering, this function is called from a secondary thread. On Windows and Linux this is not an issue, but on OSX calling this function for another thread leads to an invalid pointer. For a full list of the threading limitations with glfw functions, go to the glfw website: http://www.glfw.org/docs/latest/group__window.html#ga5c336fddf2cbb5b92f65f10fb6043344

@liavt
Copy link
Owner

liavt commented Jul 23, 2017

I can fix this soon. It's a very simple fix

@liavt
Copy link
Owner

liavt commented Jul 23, 2017

Were you using the unstable branch or master branch? This should have been fixed in the unstable code.

@liavt
Copy link
Owner

liavt commented Jul 23, 2017

Just checked the docs. Unstable does not call glfwpollevents in the main thread. I am working on a fix right now.

@sharhar
Copy link
Collaborator Author

sharhar commented Jul 23, 2017

Ok, I was using the stable branch because I thought that it would have the smallest chance of crashing. I guess I was wrong... I'll try though the unstable branch

@liavt
Copy link
Owner

liavt commented Jul 23, 2017 via email

@liavt
Copy link
Owner

liavt commented Jul 23, 2017 via email

@sharhar
Copy link
Collaborator Author

sharhar commented Jul 23, 2017

I just tested the unstable branch. The same problem persists. The function must be called from the main thread. That's just how OSX works.

@sharhar
Copy link
Collaborator Author

sharhar commented Jul 23, 2017

Also, I saw the the glfwPollEvents function is called in the main loop for every window. It should only be called from one thread (the main one) per frame. The one call deals with all windows. If it is called from two separate threads in windows it will crash.

@liavt
Copy link
Owner

liavt commented Jul 23, 2017 via email

@liavt
Copy link
Owner

liavt commented Jul 23, 2017

I just pushed a quick fix to unstable. glfwPollEvents now gets called by main thread. Try to see if it runs now.

Doing so created a strange error on my machine - glfwTerminate() somewhere along the way uses a Win32 that generates ERROR_INVALID_HANDLE. I know this because suddenly GetLastError() returns ERROR_INVALID_HANDLE after calling glfwTerminate(). This was causing crashes on my Windows machine. For now, glfwTerminate() is not in the code just to get it to run - bad practice, I know. I want to see if it works on OSX first before trying to fix the strange glfwTerminate() error

Also it somehow broke something completely unrelated - the MACE-Text demo. That is also going to be fixed after this issue is closed.

@sharhar

@liavt
Copy link
Owner

liavt commented Jul 24, 2017

Wow! GLFW has a bug! MACE kept crashing for some reason after changing the new GLFW... I created an issue in the GLFW repo (glfw/glfw#1053)

liavt added a commit that referenced this issue Jul 24, 2017
The GetLastError() bug is referenced in glfw/glfw#1053

For now, os::clearError() is called after glfwTerminate() as a workaround
to the bug
@Silentize
Copy link

Has it been fixed??

@liavt
Copy link
Owner

liavt commented Dec 9, 2019

Can't test it as I don't have a mac, feel free to try

@Silentize
Copy link

I don't have one either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants