curv3d / curv

a language for making art using mathematics
Apache License 2.0
1.14k stars 73 forks source link

GL ERROR: src=33350,id=20,sev=37190 GL_INVALID_VALUE in glUseProgram #51

Closed p-e-w closed 5 years ago

p-e-w commented 5 years ago

Describe the bug Sometimes, when running a simple Curv program like cube, the viewer displays the shape, but the following lines appear in the terminal, repeated on every frame:

GL ERROR: src=33350,id=20,sev=37190 GL_INVALID_VALUE in glUseProgram
GL ERROR: src=33350,id=20,sev=37190 GL_INVALID_OPERATION in glUniform1("u_resolution"@1 has 2 components, not 1)

This does not always happen and there is no apparent pattern to when it does.

Curv Program

cube

To Reproduce Cannot be reliably reproduced, although after it happens with one expression it generally happens for all expressions that are subsequently evaluated in the same Curv session.

System Information (please complete the following information):

$ curv --version
Curv: 0.3-128-g3521724
Compiler: gcc 8.2.1 20181105 (Red Hat 8.2.1-5)
Kernel: Linux 4.19.3-200.fc28.x86_64 x86_64
GPU: Intel Open Source Technology Center, Mesa DRI Intel(R) HD Graphics 530 (Skylake GT2) 
OpenGL: 3.0 Mesa 18.0.5
doug-moen commented 5 years ago

I'm testing using Intel HD 2500 graphics and Ubuntu 16.04. So far, I am unable to reproduce this just by repeatedly running cube. At this point, I am unsure if this is a bug in Curv or a bug in your graphics driver.

If there is an error printed on every frame, then the OpenGL program is in a bad state, and there was probably a more meaningful error printed initially, before the cascade of per-frame messages started spewing. I can probably do a better job of managing the OpenGL error messages.

doug-moen commented 5 years ago

The latest version of Curv will not go into a loop, printing OpenGL error messages on each frame. This means you should see higher quality error messages the next time this bug occurs, and those error messages should help in narrowing down what the problem is.

doug-moen commented 5 years ago

The bug report says "Cannot be reliably reproduced, although after it happens with one expression it generally happens for all expressions that are subsequently evaluated in the same Curv session."

This suggests that the OpenGL context has got into a bad state. And the bad state seems to persist even after loading a new shape.

One of the error messages is:

GL ERROR: src=33350,id=20,sev=37190 GL_INVALID_VALUE in glUseProgram

In previous versions of Curv, after loading a shader program, I used to call glUseProgram to run the program, even if the program was invalid (because it had failed to compile). And that could lead to this error being displayed. The new version of Curv stops rendering after a shader program has failed to compile, or if OpenGL errors are reported when rendering a frame. These changes are intended to make Curv more robust, because I'm trying not to ask OpenGL to render things if the context is in an error state. These changes might even fix this bug, although I can't verify that.

I suggest you try again with the new version, and see if the bug persists. At the very least, we should get a better error message.

doug-moen commented 5 years ago

@p-e-w: I'm going to close this for now. If you can reproduce the problem with the new version of Curv, please reopen the issue and post the error messages that are generated.

p-e-w commented 5 years ago

@doug-moen This still happens with the latest master. And now I have found a reliable way to reproduce:

$ curv
curv> cube
3D shape 2×2×2      <-- close the preview window
curv> cube
3D shape 2×2×2
curv> GL ERROR: src=33350,id=20,sev=37190 GL_INVALID_VALUE in glUseProgram
GL ERROR: src=33350,id=20,sev=37190 GL_INVALID_OPERATION in glUniform1("u_resolution"@1 has 2 components, not 1)

That's it, just evaluate cube, close the preview window, then evaluate cube again. The preview window is black and the above error message (and nothing else) is printed.

doug-moen commented 5 years ago

Thank you for giving me a reproducible test case. It happens for me as well, now I can fix this.