mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.31k stars 225 forks source link

Offscreen renderer gives GLError (eglMakeCurrent) #148

Open atenpas opened 4 years ago

atenpas commented 4 years ago

After running offscreen rendering a few times, I get the following error.

[...].py", line 296, in createPointCloudFromView depth = self.renderer.render(self.scene, flags=self.flags) File "[...]/env/lib/python3.7/site-packages/pyrender/offscreen.py", line 86, in render self._platform.make_current() File "[...]/env/lib/python3.7/site-packages/pyrender/platforms/egl.py", line 198, in make_current self._egl_context File "[...]/env/lib/python3.7/site-packages/OpenGL/error.py", line 232, in glCheckError baseOperation = baseOperation, OpenGL.error.GLError: GLError( err = 12289, baseOperation = eglMakeCurrent, cArguments = ( <OpenGL._opaque.EGLDisplay_pointer object at 0x7f5c66d3cf80>, <OpenGL._opaque.EGLSurface_pointer object at 0x7f5bf8a5ae60>, <OpenGL._opaque.EGLSurface_pointer object at 0x7f5bf8a5ae60>, <OpenGL._opaque.EGLContext_pointer object at 0x7f5c62539a70>, ), result = 0 )

I'm using EGL, i.e., PYOPENGL_PLATFORM=egl, Python 3.7.5, nvidia-450 and Ubuntu 16.04.

huy-ha commented 3 years ago

Same issue here. I'm on Ubuntu 18.04, Python 3.6.12, and nvidia 435.21.

  File "/home/huy/anaconda3/envs/softgym/lib/python3.6/site-packages/pyrender/offscreen.py", line 31, in __init__
    self._create()
  File "/home/huy/anaconda3/envs/softgym/lib/python3.6/site-packages/pyrender/offscreen.py", line 149, in _create
    self._platform.init_context()
  File "/home/huy/anaconda3/envs/softgym/lib/python3.6/site-packages/pyrender/platforms/egl.py", line 192, in init_context
    self.make_current()
  File "/home/huy/anaconda3/envs/softgym/lib/python3.6/site-packages/pyrender/platforms/egl.py", line 198, in make_current
    self._egl_context
  File "/home/huy/anaconda3/envs/softgym/lib/python3.6/site-packages/OpenGL/platform/baseplatform.py", line 402, in __call__
    return self( *args, **named )
  File "/home/huy/anaconda3/envs/softgym/lib/python3.6/site-packages/OpenGL/error.py", line 232, in glCheckError
    baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
    err = 12290,
    baseOperation = eglMakeCurrent,
    cArguments = (
        <OpenGL._opaque.EGLDisplay_pointer object at 0x7efdffc1ed90>,
        <OpenGL._opaque.EGLSurface_pointer object at 0x7efdffbf18c8>,
        <OpenGL._opaque.EGLSurface_pointer object at 0x7efdffbf18c8>,
        <OpenGL._opaque.EGLContext_pointer object at 0x7efdffbb7d90>,
    ),
    result = 0
)
SuwoongHeo commented 3 years ago

In my case, my problem was creating the offscreen renderer within every loop (i.e., calling render = pyrender.OffscreenRenderer). It works okay 'osmesa' as the pyopengl platform. But, for 'egl', it seems to have a problem with automatically get rid of opengl related things. So I just put renderer.delete() that will call the self.delete() of the OffscreenRenderer inside the loop. Hope it helps.

lucasjinreal commented 2 years ago

@SuwoongHeo I don't understand what you saying. I got same rror:

/OpenGL/error.py", line 228, in glCheckError
    raise GLError(
OpenGL.error.GLError: GLError(
    err = 12290,
    baseOperation = eglMakeCurrent,
    cArguments = (
        <OpenGL._opaque.EGLDisplay_pointer object at 0x7ff528e2ccc0>,
        <OpenGL._opaque.EGLSurface_pointer object at 0x7ff528e2c2c0>,
        <OpenGL._opaque.EGLSurface_pointer object at 0x7ff528e2c2c0>,
        <OpenGL._opaque.EGLContext_pointer object at 0x7ff528e52bc0>,
    ),
    result = 0
)
Qingcsai commented 2 years ago

@SuwoongHeo I don't understand what you saying. I got same rror:

/OpenGL/error.py", line 228, in glCheckError
    raise GLError(
OpenGL.error.GLError: GLError(
  err = 12290,
  baseOperation = eglMakeCurrent,
  cArguments = (
      <OpenGL._opaque.EGLDisplay_pointer object at 0x7ff528e2ccc0>,
      <OpenGL._opaque.EGLSurface_pointer object at 0x7ff528e2c2c0>,
      <OpenGL._opaque.EGLSurface_pointer object at 0x7ff528e2c2c0>,
      <OpenGL._opaque.EGLContext_pointer object at 0x7ff528e52bc0>,
  ),
  result = 0
)

@jinfagang Just add renderer.delete() at the next line of rgb, depth = renderer.render(scene, flags=pyrender.RenderFlags.RGBA) as @SuwoongHeo said, that works for me.

domef commented 4 months ago

I have the same issue (calling renderer.delete() doesn't help). It crashes the first time I instantiate OffscreenRenderer.