pyimgui / pyimgui

Cython-based Python bindings for dear imgui
https://pyimgui.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.35k stars 180 forks source link

[Bug}: When using pyimgui some users of my program have `GLError`s #368

Open ajh123 opened 8 months ago

ajh123 commented 8 months ago

Not sure how I can reproduce the following error, anyway, some users (Linux with NVIDIA's X drivers) have the following error. I'm on Windows with the NVIDA's drivers and I cannot reproduce the error.

Traceback (most recent call last):
  File "/tmp/python-minecraft-clone/community/main.py", line 460, in <module>
    main()
  File "/tmp/python-minecraft-clone/community/main.py", line 457, in main
    game.run()
  File "/tmp/python-minecraft-clone/community/main.py", line 436, in run
    pyglet.app.run(interval = 0)
  File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/__init__.py", line 76, in run
    event_loop.run(interval)
  File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/base.py", line 163, in run
    timeout = self.idle()
              ^^^^^^^^^^^
  File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/base.py", line 224, in idle
    self.clock.call_scheduled_functions(dt)
  File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/clock.py", line 180, in call_scheduled_functions
    item.func(dt, *item.args, **item.kwargs)
  File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/base.py", line 118, in _redraw_windows
    window.dispatch_event('on_draw')
  File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/window/__init__.py", line 671, in dispatch_event
    super().dispatch_event(*args)
  File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/event.py", line 387, in dispatch_event
    if getattr(self, event_type)(*args):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/python-minecraft-clone/community/main.py", line 420, in on_draw
    self.impl.render(imgui.get_draw_data())
  File "/home/obiwac/.local/lib/python3.11/site-packages/imgui/integrations/pyglet.py", line 219, in render
    super(PygletProgrammablePipelineRenderer, self).render(draw_data)
  File "/home/obiwac/.local/lib/python3.11/site-packages/imgui/integrations/opengl.py", line 149, in render
    common_gl_state_tuple = get_common_gl_state()
                            ^^^^^^^^^^^^^^^^^^^^^
  File "/home/obiwac/.local/lib/python3.11/site-packages/imgui/integrations/opengl.py", line 347, in get_common_gl_state
    last_texture = gl.glGetIntegerv(gl.GL_TEXTURE_BINDING_2D)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/latebind.py", line 43, in __call__
    return self._finalCall( *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/wrapper.py", line 678, in wrapperCall
    raise err
  File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/wrapper.py", line 671, in wrapperCall
    result = wrappedOperation( *cArguments )
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/error.py", line 230, in glCheckError
    raise self._errorClass(
OpenGL.error.GLError: GLError(
        err = 1280,
        description = b'invalid enumerant',
        baseOperation = glGetIntegerv,
        pyArgs = (
                GL_TEXTURE_BINDING_2D,
                <object object at 0x83e0c7d60>,
        ),
        cArgs = (
                GL_TEXTURE_BINDING_2D,
                array([3], dtype=int32),
        ),
        cArguments = (
                GL_TEXTURE_BINDING_2D,
                array([3], dtype=int32),
        )
)

Python dependencies

pyglet >= 2.0.10
nbtlib >= 2.0.4
base36 >= 0.1.1
pyglm >= 2.7.1
numpy >= 1.26.2
imgui[pyglet] >= 2.0.0
pillow >= 9.3.0
PyOpenGL >= 3.1.6

More information in https://github.com/obiwac/python-minecraft-clone/pull/104. The code in question is https://github.com/ajh123/python-minecraft-clone/tree/ui_rewrite/community. Currently I am not sure on the environment the user is running the program in.

obiwac commented 8 months ago

Have you tried setting debug_gl yet? Here are my logs, but I don't think there's anything in there which can help debugging:

[LOGS]
[2023-12-27 13:52:53,192] [MainProcess/MainThread/INFO] (main.py/__init__) System Info: Python: CPython 3.11.5
System: amd64 FreeBSD 13.2-RELEASE-p2 FreeBSD 13.2-RELEASE-p2 GENERIC
CPU: amd64
Display: NVIDIA GeForce GTX 1060 3GB/PCIe/SSE2 
(3, 3)

I can help debugging, I'm just a bit busy for the next couple days :)

ajh123 commented 8 months ago

@obiwac For me with pyglet.options["debug_gl"] = True I do not get any errors. Strange, isn't it?

obiwac commented 8 months ago

Indeed 🤔

I'll have a look then in a little while.

ajh123 commented 8 months ago

no_errors_here

obiwac commented 8 months ago

ah but have you tried this without your changes? i.e. in the main branch of mcpy?

ajh123 commented 8 months ago

@obiwac In episode 12 (not modified) with pyglet.options["debug_gl"] = True I get no errors.

obiwac commented 8 months ago

yes but in community I mean

ajh123 commented 8 months ago

Same results in community, no errors. Seems like NVIDIA's Windows and Linux (X) drivers behave very differently.