Skip to content
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

Bug Report: ObjCInstance b'PygletDelegate' has no attribute b'initWithAttributes_' #1089

Open
qiffang opened this issue Apr 15, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@qiffang
Copy link

qiffang commented Apr 15, 2024

Describe the bug
my computer is MacOS M1 version

the crashes log down below.

 File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyrender/pyrender/offscreen.py", line 149, in _create
    self._platform.init_context()
  File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyrender/pyrender/platforms/pyglet_platform.py", line 50, in init_context
    self._window = pyglet.window.Window(config=conf, visible=False,
  File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyglet/pyglet/window/cocoa/__init__.py", line 51, in __init__
    super().__init__(width, height, caption, resizable, style, fullscreen, visible, vsync, file_drops, display,
  File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyglet/pyglet/window/__init__.py", line 536, in __init__
    config = screen.get_best_config(config)
  File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyglet/pyglet/canvas/base.py", line 162, in get_best_config
    configs = self.get_matching_configs(template)
  File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyglet/pyglet/canvas/cocoa.py", line 59, in get_matching_configs
    return template.match(canvas)
  File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyglet/pyglet/gl/cocoa.py", line 189, in match
    pixel_format = NSOpenGLPixelFormat.alloc().initWithAttributes_(attrsArray)
  File "/Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/pyglet/pyglet/libs/darwin/cocoapy/runtime.py", line 1116, in __getattr__
    raise AttributeError('ObjCInstance %s has no attribute %s' % (self.objc_class.name, name))
AttributeError: ObjCInstance b'PygletDelegate' has no attribute b'initWithAttributes_'

pyglet version

Name: pyglet
Version: 2.0.15
Summary: pyglet is a cross-platform games and multimedia package.
Home-page: 
Author: 
Author-email: Alex Holkner & contributors <Alex.Holkner@gmail.com>
License: 
Location: /Users/qifangfang/anaconda3/envs/easymocap/lib/python3.9/site-packages
Requires: 
Required-by: pyrender

System Information:

python3 -m pyglet.info

Platform
------------------------------------------------------------------------------
platform:  macOS-13.2.1-arm64-arm-64bit
release:   22.3.0
machine:   arm64

Python
------------------------------------------------------------------------------
implementation: CPython
sys.version: 3.10.9 (main, Mar  1 2023, 12:20:14) [Clang 14.0.6 ]
sys.maxint: 9223372036854775807
PyObjC not available
os.getcwd(): /Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/myeasymocap

pyglet
------------------------------------------------------------------------------
pyglet.version: 2.0.15
pyglet.compat_platform: darwin
pyglet.__file__: /Users/qifangfang/go/src/github.com/zju3dv/EasyMocap/venv/lib/python3.10/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.window
------------------------------------------------------------------------------
display: <pyglet.canvas.cocoa.CocoaDisplay object at 0x1023dd630>
screens[0]: CocoaScreen(x=0, y=0, width=1512, height=982)
screens[1]: CocoaScreen(x=1512, y=-312, width=1920, height=1080)
config['double_buffer'] = 1
config['stereo'] = 0
config['buffer_size'] = 32
config['aux_buffers'] = 0
config['sample_buffers'] = 0
config['samples'] = 0
config['red_size'] = 0
config['green_size'] = 0
config['blue_size'] = 0
config['alpha_size'] = 8
config['depth_size'] = 32
config['stencil_size'] = 0
config['accum_red_size'] = 0
config['accum_green_size'] = 0
config['accum_blue_size'] = 0
config['accum_alpha_size'] = 0
config['major_version'] = 3
config['minor_version'] = 2
config['forward_compatible'] = None
config['opengl_api'] = 'gl'
config['debug'] = None
context: CocoaContext(id=4311563664, share=CocoaContext(id=4332575072, share=None))

window.context._info
------------------------------------------------------------------------------
gl_info.get_version(): (4, 1)
gl_info.get_vendor(): Apple
gl_info.get_renderer(): Apple M1 Pro

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

pyglet.media
------------------------------------------------------------------------------
audio driver: <pyglet.media.drivers.openal.adaptation.OpenALDriver object at 0x10662fa60>

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

pyglet.media.drivers.openal
------------------------------------------------------------------------------
Library: <CDLL '/System/Library/Frameworks/OpenAL.framework/OpenAL', handle 3e27a3b40 at 0x10665f6d0>
Version: 1.1
Extensions:
   ALC_EXT_CAPTURE
   ALC_ENUMERATION_EXT
   ALC_EXT_MAC_OSX
   ALC_EXT_ASA
   ALC_EXT_ASA_DISTORTION
   ALC_EXT_ASA_ROGER_BEEP

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

How To Reproduce
A small code example that illustrates how to reproduce the bug is very useful to help triage.

@qiffang qiffang added the bug Something isn't working label Apr 15, 2024
@benmoran56
Copy link
Member

Can you confirm if this still happens with older version of pyglet?
For example 2.0.10

@qiffang
Copy link
Author

qiffang commented Apr 15, 2024

@benmoran56 Thank you for your response
Yes, the exception still happends with 2.0.10 version

@benmoran56
Copy link
Member

I can't replicate this on an M1 Mac.

Do the pyglet examples work from the repository? Can you try examples/hello_world.py and share the results?

@TheCleric
Copy link

I'm having this intermittently, mostly in the context of some automated tests I'm running that initialize and closes many windows in series, usually with an invisible window to test some app logic. Most work well, but some seem to throw this error (of note: I'm not using pyglet directly, but via the arcade library).

I threw together this reproduction code based on the hello_world example where it seems to fail eventually (I've had it fail on as early as the 4th window, but sometimes much later):

import pyglet
import tqdm


def make_window():
    window = pyglet.window.Window(visible=False)
    label = pyglet.text.Label(
        'Hello, world!',
        font_size=36,
        x=window.width // 2,
        y=window.height // 2,
        anchor_x='center',
        anchor_y='center',
    )

    @window.event
    def on_draw():
        window.clear()
        label.draw()

    pyglet.clock.schedule_interval(lambda _: window.close(), 1.0)

    pyglet.app.run()


for i in tqdm.tqdm(range(1000)):
    make_window()

@benmoran56
Copy link
Member

It doesn't mean that your test is invalid, but multiple calls to app.run() inside of the same process is unsupported. It can potentially lead to dangling resources. You can do something like:

def null(window):
    pass

pyglet.app.event_loop.on_window_close = null

@TheCleric
Copy link

I'll accept that what I'm doing is unsupported. :)

Just to let you know though that your suggestion of the null function seems to make the window unable to close (so in my example in never gets past the first iteration of the loop).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants