[open] Error using the legacy backend
Hello,
First of all, I'm quite new to both OpenSesame and these forums so my apologies if I've asked this in the wrong place or I don't provide required information. I'm creating an experiment in which people have to sort objects on the screen into certain bins based on rules. For various reasons, I’ve written the entire thing as an inline script. I was experiencing a lot of lag when drawing the canvases, about 2 or 3 seconds just to draw 4 canvases with 5 ~2kb png images and a few lines of text. Switching to the legacy back-end seemed to fix this (though I have no experience with pygame). Now I am getting an error about 1/4 of the time I run the script, which is odd. Here is the traceback:
Traceback (most recent call last):
File "dist\libopensesame\inline_script.py", line 150, in run
File "<string>", line 299, in <module>
File "<string>", line 182, in runTrial
File "<string>", line 38, in drawCanvas
File "dist\openexp\_canvas\legacy.py", line 849, in image
TypeError: unsupported operand type(s) for -=: 'tuple' and 'int'
Traceback (most recent call last):
File "dist\libqtopensesame\qtopensesame.py", line 1393, in run_experiment
File "dist\libopensesame\experiment.py", line 287, in run
File "dist\libopensesame\sequence.py", line 55, in run
File "dist\libopensesame\inline_script.py", line 152, in run
inline_error: Error: Inline script error
In: main (run phase)
File "dist\openexp\_canvas\legacy.py", line 849, in image
Python traceback:
TypeError: unsupported operand type(s) for -=: 'tuple' and 'int'
First of all, is there some way I can actually view the offending line? I can’t seem to find legacy.py and I don’t know how to access the code that’s been “translated” (if that’s how it works) into pygame.
In any case, it seems to be taking issue with the function drawCanvas which I define in the script as,
def drawCanvas(canvas, imageList, textList): #imageList and textList are lists of triples, (path,x,y)
for image in imageList:
canvas.image(image[0],x=image[1],y=image[2])
for string in textList:
canvas.text(string[0],x=string[1],y=string[2],html=True)
If anyone knows why this would result in the error (mysteriously, only about 1/4 of the time) that’d be great but what I would really like to know is how to look at the pygame code as it appears at runtime. Alternatively, if there is some likely reason I was getting lag in Expyriment that would be useful information – perhaps I could sidestep this issue by switching back. Please let me know if more information is required.
Thanks!
Comments
Hi Noah,
The following lines from your output tell you where in your inline script the errors come from:
The problem seems to occur in the following line from your code snippet:
I suspect either
image[1]
orimage[2]
is not an integer (as it should be), but a tuple (which it seems to be for some reason). You could try printing both to the Debug Window to check what they actually are, by adding the following line to your script, directly above the line in which you draw the image:If this shows something else then x and y being two integers (as I suspect), then this will most likely pinpoint your problem.
Just to explain the running of the PyGame code: based on your inline script and the canvas back-end, classes will be used from the scripts in this module. In your case, the method that's being used to draw an image, is this one.
The xpyriment back-end may be slower on your setup, due to its blocking flip: it waits for the start of the vertical refresh, before continuing code execution. The same goes for the psycho back-end, although the latter uses different (GPU rather than CPU based) drawing methods. Although I have the same experience with xpyriment being generally slower than the other back-ends, this seems to be very platform and computer dependent.