open-cogsci / OpenSesame

Graphical experiment builder for the social sciences
http://osdoc.cogsci.nl/
GNU General Public License v3.0
234 stars 111 forks source link

Psychopy backend suddenly stopped working / Unexpected Error / pyglet.gl.lib.GLException: b'invalid value' #812

Open behinger opened 2 weeks ago

behinger commented 2 weeks ago

We got a weird problem since last week. As far as we are aware, only a new microphone was newly plugged in (windows 11 probably installs drivers). Could be related, could be unrelated, who knows. Since around that time, psychopy backend doesnt work anymore.

I really dont know how to debug this any further. I checked for graphics drivers and removed the microphone for now. I installed newest windows updates and checked that no driver/update was installed via windows update in that time period.

Anything I can do besides completly reinstalling the windows computer?

Given that we have a university course running their experiments right now, it would be great to get some input how I can debug this further. I'm willing to spend the time, but I dont really know anylonger where to look for this issue / what to try.

Best, Bene

[1] The debug.log

[2024-06-24 12:20:52,059:experiment:260:DEBUG] building experiment
[2024-06-24 12:20:52,059:item_store:152:DEBUG] creating sequence
[2024-06-24 12:20:52,059:item_store:163:DEBUG] loading core item 'sequence' from 'libopensesame'
[2024-06-24 12:20:52,059:item_store:152:DEBUG] creating notepad
[2024-06-24 12:20:52,059:plugin_manager:69:DEBUG] finding plugin runtime for notepad
[2024-06-24 12:20:52,059:plugin_manager:75:DEBUG] building plugin gui for notepad
[2024-06-24 12:20:52,059:item_store:152:DEBUG] creating sketchpad
[2024-06-24 12:20:52,059:item_store:163:DEBUG] loading core item 'sketchpad' from 'libopensesame'
[2024-06-24 12:20:53,567:psycho:142:INFO] waitblanking = True
[2024-06-24 12:20:53,567:psycho:143:INFO] monitor = testMonitor
[2024-06-24 12:20:53,567:psycho:144:INFO] screen = 0
[2024-06-24 12:20:55,381:experiment:345:INFO] experiment started
[2024-06-24 12:20:55,381:experiment:349:INFO] disabling garbage collection
[2024-06-24 12:20:55,407:updater:241:DEBUG] checking update process
[2024-06-24 12:20:55,407:updater:244:DEBUG] update process still running
[2024-06-24 12:20:55,426:experiment:419:INFO] enabling garbage collection
[2024-06-24 12:20:55,426:base_runner:276:WARNING] re-installing missing gettext built-in
[2024-06-24 12:20:55,427:_extension_manager:152:DEBUG] firing set_workspace_globals
[2024-06-24 12:20:55,433:_extension_manager:152:DEBUG] firing end_experiment
[2024-06-24 12:20:55,437:jupyter_console:84:DEBUG] releasing stdout
[2024-06-24 12:20:55,439:backend:184:DEBUG] resuming share_id: text1
[2024-06-24 12:20:55,443:backend:167:DEBUG] starting share_id: text1 (PID=7020)
[2024-06-24 12:20:55,444:_extension_manager:152:DEBUG] firing register_subprocess
[2024-06-24 12:20:55,444:subprocess_manager:143:DEBUG] 7020: BackendProcess:TextCodeEdit
[2024-06-24 12:20:55,444:console_bridge:36:DEBUG] 
Error: OSException

Unexpected error

This error occurred in the run phase of item welcome.

[2] the openGL pyglet error

['Traceback (most recent call last):', '  File "C:\\Program Files (x86)\\OpenSesame\\Lib\\site-packages\\libopensesame\\inline_script.py", line 84, in run', '    self.workspace._exec(self.crun)', '  File "C:\\Program Files (x86)\\OpenSesame\\Lib\\site-packages\\libopensesame\\base_python_workspace.py", line 99, in _exec', '    exec(bytecode, self._globals)  # __ignore_traceback__', '    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', '  File "<string>", line 3, in <module>', '  File "C:\\Program Files (x86)\\OpenSesame\\Lib\\site-packages\\openexp\\_canvas\\psycho.py", line 99, in show', '    e.show()', '  File "C:\\Program Files (x86)\\OpenSesame\\Lib\\site-packages\\openexp\\_canvas\\_element\\psycho.py", line 37, in show', '    self._stim.draw()', '  File "C:\\Program Files (x86)\\OpenSesame\\Lib\\site-packages\\psychopy\\visual\\shape.py", line 330, in draw', '    GL.glUseProgram(_prog)', '  File "C:\\Program Files (x86)\\OpenSesame\\Lib\\site-packages\\pyglet\\gl\\lib.py", line 106, in errcheck', '    raise GLException(msg)', "pyglet.gl.lib.GLException: b'invalid value'"]

Error: PythonError

Error while executing inline script (run phase)

This error occurred on line 106 in the run phase of item new_inline_script.

Traceback (most recent call last):
  File "<new_inline_script.run>", line 3, in <module>
  File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\_canvas\psycho.py", line 99, in show
    e.show()
  File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\openexp\_canvas\_element\psycho.py", line 37, in show
    self._stim.draw()
  File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\psychopy\visual\shape.py", line 330, in draw
    GL.glUseProgram(_prog)
  File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\pyglet\gl\lib.py", line 106, in errcheck
    raise GLException(msg)
pyglet.gl.lib.GLException: b'invalid value'

small edit - the full startup log from the console

Jupyter QtConsole 5.4.3
Python 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 17:59:51) [MSC v.1935 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

<frozen importlib._bootstrap>:241: RuntimeWarning: Your system is avx2 capable but pygame was not built with support for it. The performance of some of your blits could be adversely affected. Consider enabling compile time detection with environment variables like PYGAME_DETECT_AVX2=1 if you are compiling without cross compilation.
pygame 2.5.0 (SDL 2.26.5, Python 3.11.4)
Hello from the pygame community. https://www.pygame.org/contribute.html
[606.  44.]

Error: OSException

Unexpected error

This error occurred in the run phase of item welcome.
smathot commented 2 weeks ago

This seems like an issue with OpenGL, which can be very system- and version-specific. It's not directly related to OpenSesame or PsychoPy, and it's probably not something that you can debug in a meaningful way, other than through trial and error. Possibly it's indeed triggered by a driver installation, but that's hard to say.

I would probably first see if there are (video) updates available for the computer. If this doesn't solve the issue, then I would build a new anaconda environment with OpenSesame in the hope that in this environment the error doesn't resurface.

behinger commented 2 weeks ago

Thanks for yor response. I don't understand how it can be an opengl issue, if it works when calling manually via the "Opensesame python module (no gui").

I also reinstalled via the installer - isn't this equivalent to reinstalling via anaconda? I'm not doubting or so - I'm just collecting debugging ideas until I (or @tmalsburg) can be back in the lab

smathot commented 2 weeks ago

I don't understand how it can be an opengl issue, if it works when calling manually via the "Opensesame python module (no gui").

I suspect that when you use the OpenSesame Python module, you're doing this in a different Python environment. Is that correct? If not, then that would indeed be strange.

By saying that it's an OpenGL issue I mainly mean that it in general terms originates from OpenGL—I can see that from the error message. But what the underlying cause is exactly is hard to tell.

I also reinstalled via the installer - isn't this equivalent to reinstalling via anaconda? I'm not doubting or so - I'm just collecting debugging ideas until I (or @tmalsburg) can be back in the lab

OpenSesame is indeed built on an Anaconda environment. However, if you install your own Anaconda environment, you will end up with slightly different versions of all packages, possibly even a different version of Python. And since this issue is quite likely version-specific, this might do the trick.

behinger commented 2 weeks ago

I am using the opensesame environment, there is no other python installed - so we are in strange territory... Any way to get opensesame to return even more debugging information?

smathot commented 2 weeks ago

The offending GL call originates from psychopy here:

I don't know enough about OpenGL to say what this does, or what the role _prog object is. But if within the exact same environment you get an error when running in the context of the GUI, and not in the context of a standalone script, then perhaps the issue lies here. Simply printing out what this is by a line to that file (print(_prog, type(_prog))) may be informative.

As I said before though, these things can be super context-dependent in the sense that it crashes in one situation and runs fine in another seemingly identical situation. And that can make it practically impossible to debug.