pyglet / pyglet

pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.
http://pyglet.org
BSD 3-Clause "New" or "Revised" License
1.9k stars 307 forks source link

pyglet crashes at pyglet.window #1225

Open joshgura opened 1 month ago

joshgura commented 1 month ago

i get the following output and error messages after executing the diagnostic tool python -m pyglet.info

trying to find out why a python app won't start, and it traces to some pyglet related stuff. could aslo be python-gobject or opengl, gxl libaries, or something else.

`Platform

platform: Linux-6.6.56-1-lts-x86_64-with-glibc2.40 release: 6.6.56-1-lts machine: x86_64

Python

implementation: CPython sys.version: 3.11.10 (main, Oct 3 2024, 07:29:13) [GCC 11.2.0] sys.maxint: 9223372036854775807 os.getcwd(): /home/username

pyglet

pyglet.version: 1.5.23 pyglet.compat_platform: linux pyglet.file: /home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/init.py pyglet.options['audio'] = ('xaudio2', 'directsound', 'openal', 'pulse', 'silent') pyglet.options['debug_font'] = False pyglet.options['debug_gl'] = True pyglet.options['debug_gl_trace'] = False pyglet.options['debug_gl_trace_args'] = False pyglet.options['debug_graphics_batch'] = False pyglet.options['debug_lib'] = False pyglet.options['debug_media'] = False pyglet.options['debug_texture'] = False pyglet.options['debug_trace'] = False pyglet.options['debug_trace_args'] = False pyglet.options['debug_trace_depth'] = 1 pyglet.options['debug_trace_flush'] = True pyglet.options['debug_win32'] = False pyglet.options['debug_x11'] = False pyglet.options['graphics_vbo'] = True pyglet.options['shadow_window'] = True pyglet.options['vsync'] = None pyglet.options['xsync'] = True pyglet.options['xlib_fullscreen_override_redirect'] = False pyglet.options['darwin_cocoa'] = True pyglet.options['search_local_libs'] = True pyglet.options['advanced_font_features'] = False pyglet.options['headless'] = False pyglet.options['headless_device'] = 0 pyglet.options['win32_disable_shaping'] = False

pyglet.window

Traceback (most recent call last): File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 225, in _try_dump func() File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 97, in dump_window import pyglet.window File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/init.py", line 1918, in gl._create_shadow_window() File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/init.py", line 206, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/xlib/init.py", line 171, in init super(XlibWindow, self).init(*args, **kwargs) File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/init.py", line 600, in init config = screen.get_best_config(template_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/canvas/base.py", line 192, in get_best_config configs = self.get_matching_configs(template) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/canvas/xlib.py", line 220, in get_matching_configs configs = template.match(canvas) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/xlib.py", line 58, in match have_13 = info.have_version(1, 3) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/glx_info.py", line 86, in have_version client_version = self.get_client_version().split()[0]


IndexError: list index out of range

pyglet.gl.glu_info
------------------------------------------------------------------------------
/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/glu_info.py:123: UserWarning: No GL context created yet.
  warnings.warn('No GL context created yet.')
glu_info.get_version(): 0.0.0
glu_info.get_extensions():
/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/glu_info.py:148: UserWarning: No GL context created yet.
  warnings.warn('No GL context created yet.')

pyglet.gl.glx_info
------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 225, in _try_dump
    func()
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 148, in dump_glx
    window = pyglet.window.Window(visible=False)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/xlib/__init__.py", line 171, in __init__
    super(XlibWindow, self).__init__(*args, **kwargs)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 600, in __init__
    config = screen.get_best_config(template_config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/canvas/base.py", line 192, in get_best_config
    configs = self.get_matching_configs(template)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/canvas/xlib.py", line 220, in get_matching_configs
    configs = template.match(canvas)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/xlib.py", line 58, in match
    have_13 = info.have_version(1, 3)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/glx_info.py", line 86, in have_version
    client_version = self.get_client_version().split()[0]
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

pyglet.media
------------------------------------------------------------------------------
audio driver: <pyglet.media.drivers.pulse.adaptation.PulseAudioDriver object at 0x7faa20387090>

pyglet.media.ffmpeg
------------------------------------------------------------------------------
FFmpeg not available.

pyglet.media.drivers.openal
------------------------------------------------------------------------------
OpenAL not available.

pyglet.input.wintab
------------------------------------------------------------------------------
WinTab not available.
`

here's my glxinfo
```

(/home/username/opt/UVR/env) [username@thing ~]$ glxinfo | grep 'direct rendering:'
direct rendering: Yes
(/home/username/opt/UVR/env) [username@thing ~]$ glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: Mesa Intel(R) HD Graphics 4600 (HSW GT2)
(/home/username/opt/UVR/env) [username@thing ~]$ glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: Mesa Intel(R) HD Graphics 4600 (HSW GT2)
```

it's a little weird that opengl is still using my cpu instead of my gpu but that's something else that might not be related to this issue.

any tips? also it's weird that it says ffmpeg is not available since i've got it on my base install, and in the venv i'm using.
joshgura commented 1 month ago

that's an old version of pyglet in the requirements for ultimate vocal remover.

i've also tried to uninstall that and install the pyglet latest and here's the traceback of an info test:

Platform
------------------------------------------------------------------------------
platform:  Linux-6.6.56-1-lts-x86_64-with-glibc2.40
release:   6.6.56-1-lts
machine:   x86_64

Python
------------------------------------------------------------------------------
implementation: CPython
sys.version: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]
sys.maxint: 9223372036854775807
os.getcwd(): /home/username

pyglet
------------------------------------------------------------------------------
pyglet.version: 2.0.18
pyglet.compat_platform: linux
pyglet.__file__: /home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/__init__.py
pyglet.options['audio'] = ('xaudio2', 'directsound', 'openal', 'pulse', 'silent')
pyglet.options['debug_font'] = False
pyglet.options['debug_gl'] = True
pyglet.options['debug_gl_trace'] = False
pyglet.options['debug_gl_trace_args'] = False
pyglet.options['debug_gl_shaders'] = False
pyglet.options['debug_graphics_batch'] = False
pyglet.options['debug_lib'] = False
pyglet.options['debug_media'] = False
pyglet.options['debug_texture'] = False
pyglet.options['debug_trace'] = False
pyglet.options['debug_trace_args'] = False
pyglet.options['debug_trace_depth'] = 1
pyglet.options['debug_trace_flush'] = True
pyglet.options['debug_win32'] = False
pyglet.options['debug_input'] = False
pyglet.options['debug_x11'] = False
pyglet.options['shadow_window'] = True
pyglet.options['vsync'] = None
pyglet.options['xsync'] = True
pyglet.options['xlib_fullscreen_override_redirect'] = False
pyglet.options['search_local_libs'] = True
pyglet.options['win32_gdi_font'] = False
pyglet.options['headless'] = False
pyglet.options['headless_device'] = 0
pyglet.options['win32_disable_shaping'] = False
pyglet.options['dw_legacy_naming'] = False
pyglet.options['win32_disable_xinput'] = False
pyglet.options['com_mta'] = False
pyglet.options['osx_alt_loop'] = False
pyglet.options['shader_bind_management'] = True

pyglet.window
------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 178, in _try_dump
    func()
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 62, in dump_window
    from pyglet.gl import gl_info
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 197, in <module>
    import pyglet.window  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 1794, in <module>
    gl._create_shadow_window()  # noqa: SLF001
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 171, in _create_shadow_window
    _shadow_window = ShadowWindow()
                     ^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 166, in __init__
    super().__init__(width=1, height=1, visible=False)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/xlib/__init__.py", line 168, in __init__
    super().__init__(*args, **kwargs)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 517, in __init__
    raise NoSuchConfigException(msg)
pyglet.window.NoSuchConfigException: No standard config is available.

pyglet.gl.glx_info
------------------------------------------------------------------------------
GLX not available.

pyglet.media
------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 178, in _try_dump
    func()
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 125, in dump_media
    import pyglet.media
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/media/__init__.py", line 48, in <module>
    from .player import Player, PlayerGroup
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/media/player.py", line 11, in <module>
    from pyglet.gl import GL_TEXTURE_2D
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 197, in <module>
    import pyglet.window  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 1794, in <module>
    gl._create_shadow_window()  # noqa: SLF001
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 171, in _create_shadow_window
    _shadow_window = ShadowWindow()
                     ^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 166, in __init__
    super().__init__(width=1, height=1, visible=False)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/xlib/__init__.py", line 168, in __init__
    super().__init__(*args, **kwargs)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 517, in __init__
    raise NoSuchConfigException(msg)
pyglet.window.NoSuchConfigException: No standard config is available.

pyglet.media.ffmpeg
------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 178, in _try_dump
    func()
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/info.py", line 133, in dump_ffmpeg
    import pyglet.media
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/media/__init__.py", line 48, in <module>
    from .player import Player, PlayerGroup
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/media/player.py", line 11, in <module>
    from pyglet.gl import GL_TEXTURE_2D
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 197, in <module>
    import pyglet.window  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 1794, in <module>
    gl._create_shadow_window()  # noqa: SLF001
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 171, in _create_shadow_window
    _shadow_window = ShadowWindow()
                     ^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 166, in __init__
    super().__init__(width=1, height=1, visible=False)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/xlib/__init__.py", line 168, in __init__
    super().__init__(*args, **kwargs)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 517, in __init__
    raise NoSuchConfigException(msg)
pyglet.window.NoSuchConfigException: No standard config is available.

pyglet.media.drivers.openal
------------------------------------------------------------------------------
OpenAL not available.

pyglet.input.wintab
------------------------------------------------------------------------------
WinTab not available.
Exception ignored in atexit callback: <function _delete_audio_driver at 0x77f6fe50dbc0>
Traceback (most recent call last):
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/media/drivers/__init__.py", line 79, in _delete_audio_driver
    from .. import Source
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/media/__init__.py", line 48, in <module>
    from .player import Player, PlayerGroup
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/media/player.py", line 11, in <module>
    from pyglet.gl import GL_TEXTURE_2D
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 197, in <module>
    import pyglet.window  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 1794, in <module>
    gl._create_shadow_window()  # noqa: SLF001
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 171, in _create_shadow_window
    _shadow_window = ShadowWindow()
                     ^^^^^^^^^^^^^^
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/gl/__init__.py", line 166, in __init__
    super().__init__(width=1, height=1, visible=False)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/xlib/__init__.py", line 168, in __init__
    super().__init__(*args, **kwargs)
  File "/home/username/opt/UVR/env/lib/python3.11/site-packages/pyglet/window/__init__.py", line 517, in __init__
    raise NoSuchConfigException(msg)
pyglet.window.NoSuchConfigException: No standard config is available.
benmoran56 commented 1 month ago

Hi,

For ffmpeg, we only explicitly support v4 and v5. Newer versions need testing, and may have some slight API differences. Most distros are still shipping <= 5, so it has not been gotten around to yet. Do you need support for compressed audio formats? GStreamer will also work if installed, providing you have the Python bindings as well (these tend to be part of the meta package).

For your GL issue, it's something driver related. What do you get from glxinfo | grep OpenGL? Your graphics hardware should support up to GL 4.0 I believe. As a sanity check, you could try booting from some Linux live USB. From there, pip install pyglet and try pyglet.info again, then the hello_world.py example from Github.

joshgura commented 1 month ago

Hi,

For ffmpeg, we only explicitly support v4 and v5. Newer versions need testing, and may have some slight API differences. Most distros are still shipping <= 5, so it has not been gotten around to yet. Do you need support for compressed audio formats? GStreamer will also work if installed, providing you have the Python bindings as well (these tend to be part of the meta package).

For your GL issue, it's something driver related. What do you get from glxinfo | grep OpenGL? Your graphics hardware should support up to GL 4.0 I believe. As a sanity check, you could try booting from some Linux live USB. From there, pip install pyglet and try pyglet.info again, then the hello_world.py example from Github.

I'm trying to run Ultimate Vocal Remover, and I see the same potential pyglet issue showing up for a lot of different folks on linux, so it's a shot in the dark as to whether it's a pyglet related thing. I notice that my cpu is doing the job of opengl rendering, which it a nuisance because I've got a 3060 nvidia gpu. that's a can of worms, seems like there's 50 nvidia drivers needed as it is, (every time i install one of the latest killer apps using torch, loads of nvidia drivers...) but globally i probably need to figure out how to marry opengl to the gpu, but it's a digression.

output of glxinfo...

$ glxinfo | grep OpenGL
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) HD Graphics 4600 (HSW GT2)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 24.2.4-arch1.1
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 24.2.4-arch1.1
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.2.4-arch1.1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

arg, that was it... until i move opengl over to my gpu from my integrated graphics, i am using the following modifer before i launch with the python command:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia python3 ...

benmoran56 commented 1 month ago

Do you mean manually setting the environmental flags is working to get your NVidia in use?

joshgura commented 1 month ago

yes, the nvidia-prime flag did the trick for me. for some reason at some time in my vanilla arch installation, openGL stuck with integrated graphics, but i do have prime installed, and that flag i found on the arch wiki allowed the app i am running to proceed with its pyglet implementation. it may be just an idiosynchracy of the app, which is again, ultimate vocal remover. i havent noticed whether other apps use pyglet or not.

On Sun, Oct 13, 2024, 03:49 Benjamin @.***> wrote:

Do you mean manually setting the environmental flags is working to get your NVidia in use?

— Reply to this email directly, view it on GitHub https://github.com/pyglet/pyglet/issues/1225#issuecomment-2408780019, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQCGBTLWVMDRJ3SYKTHARDZ3HGSJAVCNFSM6AAAAABP2AVK6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBYG44DAMBRHE . You are receiving this because you authored the thread.Message ID: @.***>