-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix glfw3 default hints being modified #20770
Fix glfw3 default hints being modified #20770
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with some comments
|
||
// reset hints | ||
glfwDefaultWindowHints(); | ||
assert(EM_ASM_INT(return GLFW.hints[0x00021005];) == 24); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you can test this without using EM_JS
and instead using glfwGetWindowParam
?
Then maybe we can avoiding hardcoded values like 0x00021005 in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that glfwGetWindowParam
is not part of the GLW3 api. According to the documentation it has been replaced by glfwGetWindowAttrib
, but it requires a window as an argument which I don't have in the test because I never create a window.
@sbc100 I have updated the PR according to your feedback. Looking at the source code, I noticed this as well this.attributes = GLFW.hints; which is a similar "mistake" and should probably be fixed. If you write a test code like this: glfwDefaultWindowHints();
glfwWindowHint(GLFW_DEPTH_BITS, 16);
window = glfwCreateWindow(...)
assert(glfwGetWindowAttrib(window, GLFW_DEPTH_BITS) == 16);
// this changes the window hints and due to the shallow copy,
// also the attributes of the window just created...
glfwWindowHint(GLFW_DEPTH_BITS, 24);
assert(glfwGetWindowAttrib(window, GLFW_DEPTH_BITS) == 16); // this will fail... Do you want me to fix it part of this PR as well? // trivial fix...
this.attributes = Object.assign({}, GLFW.hints); |
- added test for it
@sbc100 I ended up fixing the attributes assignment as well since it is such a trivial fix (and added a test for it) I don't understand why so many tests failed and they seem to be unrelated to my changes. The test that I added passes ok:
|
Can you try merging (or rebasing) to get the latest changes from the main branch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
The last update is already up to date with main. I will try again when there is a new commit. |
I just landed b7924c4. Can you rebase or merge on top of that? |
There has been some progress, but still some tests failure which I believe are unrelated to my changes:
|
Everything is green! Yay! |
I fixed the small indentation issues and everything still green :) |
The code is doing:
GLFW.hints = GLFW.defaultHints
which is assigning the objectGLFW.defaultHints
to theGLFW.hints
and not copying its value. As a result setting any hint after the fact (usingglfwWindowHint
) modifies theGLFW.defaultHints
and as a resultglfwDefaultWindowHints
is not restoring the defaults.The purpose of this PR is to fix this problem. I also added a test for it.