More GLViewWidget don't work at the same time !!

1,307 views
Skip to first unread message

Mattia Torta

unread,
May 13, 2014, 8:13:29 AM5/13/14
to pyqt...@googlegroups.com
Hello everyone,

i'm developing an application that includes pyqtgraph for data visualization and i'm trying to open more than one 3D plot at the same time, but i receive this error whenever more than one GLViewWidget() are opened.

This is the error:

    |==============================>>
    |  Traceback (most recent call last):
    |    File "C:\Program Files (x86)\Python33\lib\idlelib\run.py", line 121, in main
    |      seq, request = rpc.request_queue.get(block=True, timeout=0.05)
    |    File "C:\Program Files (x86)\Python33\lib\queue.py", line 175, in get
    |      raise Empty
    |  queue.Empty
    |  
    |  During handling of the above exception, another exception occurred:
    |  
    |  Traceback (most recent call last):
    |    File "C:\Program Files (x86)\Python33\lib\site-packages\pyqtgraph\opengl\GLViewWidget.py", line 180, in drawItemTree
    |      i.paint()
    |    File "C:\Program Files (x86)\Python33\lib\site-packages\pyqtgraph\opengl\items\GLMeshItem.py", line 166, in paint
    |      with self.shader():
    |    File "C:\Program Files (x86)\Python33\lib\site-packages\pyqtgraph\opengl\shaders.py", line 317, in __enter__
    |      glUseProgram(self.program())
    |    File "errorchecker.pyx", line 53, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError (D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\errorchecker.c:1218)
    |  OpenGL.error.GLError: GLError(
    |   err = 1281,
    |   description = b'valore non valido',
    |   baseOperation = glUseProgram,
    |   cArguments = (3,)
    |  )
    |  
    |==============================<<
Error while drawing item <pyqtgraph.opengl.items.GLSurfacePlotItem.GLSurfacePlotItem object at 0x05D5C418>.


Thanks in advance for your help.
Mattia

Luke Campagnola

unread,
May 13, 2014, 10:38:10 AM5/13/14
to pyqt...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/5bebb672-3701-4e1b-b6ac-346dd70c24e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/.

Mattia Torta

unread,
May 19, 2014, 9:06:58 AM5/19/14
to pyqt...@googlegroups.com
I've carried out some tests and it seems that this problem is related to the shader.
Without specifying any shader, there's no problem whatsoever..

pw = gl.GLSurfacePlotItem(np.array(freqs), np.array(times), spectrogram, drawEdges = True, edgeColor = np.array([1, 0.5, 0.5, 0]))

John David Reaver

unread,
Sep 17, 2014, 8:57:17 PM9/17/14
to pyqt...@googlegroups.com
I am having a similar problem. Here is a script that reproduces the issue:
 
import numpy as np
from PySide import QtGui
import sys

import pyqtgraph.opengl as gl

app = QtGui.QApplication.instance()
if not app:
    app = QtGui.QApplication(sys.argv)

v1 = gl.GLViewWidget()
v1.addItem(gl.GLScatterPlotItem(pos=np.array([[1, 1, 1]])))
v1.show()

v2 = gl.GLViewWidget()
v2.addItem(gl.GLScatterPlotItem(pos=np.array([[1, 1, 1]])))
v2.show()

sys.exit(app.exec_())


This produces the following error:

[17:50:47]  

    |==============================>>
    |    File "pqtg-test.py", line 19, in <module>
    |      sys.exit(app.exec_())
    |    File "/home/david/miniconda3/envs/frackoptima/lib/python3.4/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 178, in paintGL
    |      self.drawItemTree(useItemNames=useItemNames)
    |    File "/home/david/miniconda3/envs/frackoptima/lib/python3.4/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 218, in drawItemTree
    |      self.drawItemTree(i, useItemNames=useItemNames)
    |    File "/home/david/miniconda3/envs/frackoptima/lib/python3.4/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 199, in drawItemTree
    |      debug.printExc()
    |    ---- exception caught ---->
    |    File "/home/david/miniconda3/envs/frackoptima/lib/python3.4/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 196, in drawItemTree
    |      i.paint()
    |    File "/home/david/miniconda3/envs/frackoptima/lib/python3.4/site-packages/pyqtgraph/opengl/items/GLScatterPlotItem.py", line 116, in paint
    |      with self.shader:
    |    File "/home/david/miniconda3/envs/frackoptima/lib/python3.4/site-packages/pyqtgraph/opengl/shaders.py", line 317, in __enter__
    |      glUseProgram(self.program())
    |    File "/home/david/miniconda3/envs/frackoptima/lib/python3.4/site-packages/OpenGL/error.py", line 232, in glCheckError
    |      baseOperation = baseOperation,
    |  OpenGL.error.GLError: GLError(
    |   err = 1281,
    |   description = b'invalid value',
    |   baseOperation = glUseProgram,
    |   cArguments = (2,)
    |  )
    |==============================<<
Error while drawing item <pyqtgraph.opengl.items.GLScatterPlotItem.GLScatterPlotItem object at 0x7f863f402408>.

From the traceback, it is clear it is a shader issue. Also, when you use a plot item that doesn't require shaders (like GLLinePlotItem), it works fine.

I am using the latest version of pyqtgraph (head of the git repo), and the latest PyOpenGL (3.1.0).

Luke Campagnola

unread,
Sep 17, 2014, 10:16:41 PM9/17/14
to pyqt...@googlegroups.com
On Wed, Sep 17, 2014 at 8:57 PM, John David Reaver <johnd...@gmail.com> wrote:
    |  OpenGL.error.GLError: GLError(
    |   err = 1281,
    |   description = b'invalid value',
    |   baseOperation = glUseProgram,
    |   cArguments = (2,)


This error makes me think that the shader programs are not being correctly shared between widgets. The script works fine on my machine (kubuntu + nVidia), though, so I am not sure what to make of that..  what OS and GPU drivers are you-all using?

Try modifying your script like this, and let me know whether it helps:

    v1 = gl.GLViewWidget()
    v1.makeCurrent()

    v1.addItem(gl.GLScatterPlotItem(pos=np.array([[1, 1, 1]])))
    v1.show()

    v2 = gl.GLViewWidget()
    v2.makeCurrent()

John David Reaver

unread,
Sep 17, 2014, 10:36:29 PM9/17/14
to pyqt...@googlegroups.com
Thanks for the response Luke. I tried your suggestion to no avail. 

I am running Arch Linux with the proprietary NVIDIA GPU drivers, but I also tried it using my CPU. In addition to that, I tried it in a Windows VM.

Furthermore, in the application I am working on, I have had the two separate GLViewWidgets for about three months now. Only recently did this problem occur, but I can't nail down exactly when it happened. That's what prompted me to make the simple script to check for the error, and of course the error is there.

I'm going to keep investigating.

--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/AOj_oRoN_fk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CACZXET-900AXO5SeChFBKCORpnR0Nuf0kY2ceuibZ_ZW%3DU6UYw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

John David Reaver

unread,
Sep 18, 2014, 2:24:36 PM9/18/14
to pyqt...@googlegroups.com
I installed python 3, PySide, PyOpenGL 3.1.0, and pyqtgraph (latest rev) on a clean Ubuntu 14.04 install on another machine. I still got the same error.

Then, I tried it with PyQt4, and the error disappeared. That's also why I couldn't find how the error was introduced. I started using a precompiled PySide package for Anaconda a couple weeks ago, but I never thought to search my git repo for a PySide change.

The fix is to use the latest version of PySide. Both the Ubuntu PySide and the Anaconda PySide used version 1.2.1, but using 1.2.2 fixes the problem.

I guess users should tell also you if they are using PyQt or PySide if another OpenGL error pops up like this in the future. Thanks for your help!

John David Reaver

unread,
Sep 18, 2014, 2:31:51 PM9/18/14
to pyqt...@googlegroups.com
Actually, I spoke to early. Using PySide 1.2.2 doesn't in fact fix the problem :(

At least it is nailed down to a difference between PySide and PyQt haha.

--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/AOj_oRoN_fk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.

Luke Campagnola

unread,
Sep 25, 2014, 10:04:16 AM9/25/14
to pyqt...@googlegroups.com
On Thu, Sep 18, 2014 at 2:31 PM, John David Reaver <johnd...@gmail.com> wrote:
Actually, I spoke to early. Using PySide 1.2.2 doesn't in fact fix the problem :(

At least it is nailed down to a difference between PySide and PyQt haha.

Thanks for investigating! This is very helpful.

John David Reaver

unread,
Sep 26, 2014, 10:52:19 AM9/26/14
to pyqt...@googlegroups.com
In my application, I have 10 3D plots, but only two of me are giving me the error. Furthermore, this only started happening about 2 weeks ago, so some innocuous change I made introduced the bug.

My other 8 plots are created on demand (not when the GUI starts) have GLScatterPlotItems in them, but they give me no trouble. After digging though the pyqtgraph source code, I uncovered lots of talk of sharing shaders. I decided to call QtOpenGL.QGLWidget.isSharing() on all of my plots. My 8 plots that work return isSharing() == True, and the two giving me trouble (like the example script I posted) have isSharing() == False.

Now here's the kicker. Here is a modified version of the script that prints isSharing() at key points:

import numpy as np
from PyQt4 import QtGui, QtOpenGL
import sys

import pyqtgraph.opengl as gl

app = QtGui.QApplication.instance()
if not app:
    app = QtGui.QApplication(sys.argv)

v1 = gl.GLViewWidget()
v1.show()
v2 = gl.GLViewWidget()
v2.show()

print("Sharing:", QtOpenGL.QGLContext.areSharing(v1.context(), v2.context()))

v1.addItem(gl.GLScatterPlotItem(pos=np.array([[1, 1, 1]])))
v2.addItem(gl.GLScatterPlotItem(pos=np.array([[1, 1, 1]])))

sys.exit(app.exec_())



When I run this with PySide, it prints "Sharing: False", then the errors discussed earlier. When I run it with PyQt4, it prints "Sharing: True" and works! It seems to me that context sharing is required for the GLScatterPlotItem shader, but for some reason, PySide doesn't use it in some instances. I wonder why PyQt always uses context sharing, and why some plots in my application use it in PySide.

I am doing more investigation as to why this is happening. However, given this information, does anyone have a clue as to how I can force context sharing in PySide? Also, I know pyqtgaph passes a static shareWidget. Is it the case that this sometimes works, and sometimes doesn't?

If anyone has any more ideas, I would love them!

--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/AOj_oRoN_fk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.

John David Reaver

unread,
Sep 26, 2014, 11:01:45 AM9/26/14
to pyqt...@googlegroups.com
Something else: the GLViewWidget.ShareWidget is being created twice. It isn't being shared by the two GLViewWidgets! See the following line in the source code:


In PySide, the line inside the if statement runs, but then immediately after the if statement, ShareWidget is still None. In PyQt4, the statement works as expected. I made ShareWidget a module-level variable instead of a static property of GLViewWidget, and then it worked in PySide!

I am wondering why you can't assign a class attribute to GLViewWidget in PySide, but you can in PyQt4. Is there some funny Python metaclass or class hierarchy activity happening in PySide that erases the static ShareWidget variable?

Also, Luke, do you think it would be acceptable to make ShareWidget a module-level declaration so this issue is fixed? If so, I can make a pull request.

Luke Campagnola

unread,
Oct 14, 2014, 9:51:48 PM10/14/14
to pyqt...@googlegroups.com
This issue should now be fixed in the develop branch thanks to John's PR.
If there are any lingering problems, please let us know!


You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CAOWTBbxcAmoha%2BUnCb1BuDkM%3D%2BWPpgd5hiDW%2BLwh%3DBwLivWV%2Bw%40mail.gmail.com.

Alex Davies

unread,
Feb 17, 2023, 11:38:10 AM2/17/23
to pyqtgraph
This does not appear to be fixed, sadly. I've re-opened the issue here if anyone feels like taking another crack at it....

https://github.com/pyqtgraph/pyqtgraph/issues/2618
Reply all
Reply to author
Forward
0 new messages