-
Notifications
You must be signed in to change notification settings - Fork 179
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
Can not initialize GLFW without joystick support #127
Comments
Can you post some example code that triggers this? Edit: We've made platform errors panic in purpose because they are supposed to be not recoverable. I will check. |
I am not sure if that's the right thing, especially for those errors that are explicitly non-fatal according to the GLFW source. There are quite a lot of such ignore / resume without ... comments in the GLFW C source. Here is a full example, but I doubt that it will be of much use. I'm still not sure why inotify isn't working for /dev/input on this system (there is plenty of available disk space of course):
Output:
|
To be honest, I really dislike all those panics in the GLFW Go binding. In my opinion, a Go library should only panic when the API is used incorrectly (i.e. programming errors). Everything else should return an error. It's fine to use panics internally, but you should recover and return a error code in your public API. |
All the recoverable errors are returned. We panic only when the error is not The problem is, all GLFW methods are allowed to raise error so for an
|
This is our intention. This looks like a bug that needs to be fixed on our end. |
It seems to me like it is a documentation discrepancy. The GLFW Error docs clearly state that
Either the documentation is incorrect -- or this is a bug with GLFW/OS. |
I've looked at It may be that the C library may return multiple errors per single func call... And not all errors are critical? |
@shurcooL Yep, I think so. In my case, the inotify failure is definitely non-critical. Everything (including joystick input) is working fine. I think the error just tells me that I might have to restart the game when I plug in an additional controller. The C library also calls the error callback so that the GLFW user can log that error for example and then CONTINUES initializing everything else. The Go binding however is unusable after the panic and there is no way to bypass the (non-fatal) error. |
My point is that either:
Before we know the answer to that -- we can't correctly fix this issue. I'd be willing to bet that the docs need updating. |
@tux21b (redacted code -- see below) |
@slimsag I think recovering here is useless, stack unwinding already happened because of the panic and glfw.Init might have been aborted prematurely. In fact, I do not think that it is possibly to work around this bug without modifying glfw/error.go. |
@tux21b You're absolutely right -- my apologies for the incorrect workaround. I've formed an issue asking for clarification on the docs -- we'll get to the bottom of this and get a fix pushed as soon as possible. |
@slimsag I am neither an GLFW developer nor an experienced GLFW user, but my understanding from using the C library is that the error callback might be called for quite a lot of things, even when glfwInit succeeds. The intended use is probably to just log those. The errors reported by the error callback might or might not be the reason for failure. The Go binding (in comparison to the C lib) seems to try to match calls of the error callback to the success / non-success status of some functions. But this seems to be flawed. glfwInit might call the error callback multiple times and still return success. In addition to that, the error callback might get called asynchronously and there might be no (or multiple) GLFW calls. So I think it would be better to stay with the GLFW C API. Therefore, glfwInit should just return true or false (or a general |
So, It looks like PlatformError is recoverable after all (glfw/glfw#450) |
Sorry for the delay on this.
I'm not yet convinced that we should return these as errors -- how on earth is the developer supposed to handle them properly aside from just printing them? (sometimes their fatal, other times not). Leaning towards the idea that these are warnings not errors to be handled, and if that's the case we could just print them to stdout/stderr. Thoughts? These functions can generate
Here's a list of the error messages that are generated (note that some of them have dynamic
|
I think that's an improvement over current behavior. I don't think it's ideal, but I can't propose something better at this time. If I have better ideas later, I'll make another comment. But we don't need to wait for that, as any improvement is worth taking a step forward and we can always revisit the issue. Additional ThoughtsWhether something is a warning or an error depends on many factors, I don't think it's a clear cut distinction that we the library makers can make for users. As an example, failed joystick init may be critical if your app uses joysticks or harmless if it doesn't. I think returning errors that can be classified in some way (ala http://dave.cheney.net/2014/12/24/inspecting-errors) is okay. Errors are values, and while |
@shurcooL I largely agree with your additional thoughts. Problem is that these errors can't be uniquely identified through GLFW, as many of them contain arbitrary strings. They're all just thrown into a "platform error" group. I'll send a PR for logging the errors next. |
Isn't @elmindreda working on improving that, according to glfw/glfw#450 (comment)? I might be reading that incorrectly though. But it seems to me that if it's possible to classify errors, it should be done upstream in GLFW C source, not in our Go wrapper. |
I read that as improving the documentation for the |
@tux21b We've merged a change that will solve the issue at hand. Please update |
How about a new error token for these non-critical platform specific errors for 3.2? |
@elmindreda having a new token like That situation would be vastly better, but if we wanted to go the extra mile I would raise the question -- if |
@slimsag What would the application do differently if it knew? |
@elmindreda if an application critically relies on being able to use the joystick (or another feature), for example, it could display a message to the user that the joystick is not available and the application cannot continue. |
It's been a long time since this issue was reported and I don't remember all the details. GLFW 3.2 is around the corner. I've already started a devel branch. What shall we do about this? Can we now implement it the way we want? I've noticed that official GLFW docs now clearly state the errors that can be caused by the methods. Does it help? |
I'm also not sure of what the issue is exactly by now, because so much time has passed. I think we should close and re-open when someone runs into this and can provide some details and updates. This issue doesn't seem very actionable right now. I just wanted to point out that there's a seemingly related issue reported in GLFW (the C library) at glfw/glfw#833. |
As suggested, If needed we can reopen it. |
I'm not quite sure what's the problem with the joystick configuration of my system, but the Go GLFW package panics with:
The error itself is triggered at
glfw/src/linux_joystick.c:_glfwInitJoysticks():213
which contains a comment in the following line saying:// Continue without device connection notifications
. Therefore, I expect everything (except discovering new joysticks) to work. Unfortunately, the GLFW Go binding is way more strict and throws a panic in this case.The text was updated successfully, but these errors were encountered: