Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Issues regarding Python crashing / pythonw.exe being unresponsive, and more..

cescocesco Posts: 26

I've been having a few issues with my experiment deciding to be funky. I use OpenSesame 3.1.6 with the PsychoPy backend and PyGaze for eye tracking with an SMI-Red500 on a dual-PC setup. The Pygaze scripts are running smoothly now, but the experiment won't complete.

The experiment is quite 'long' but shouldn't be too heavy in terms of processing. Across the experiment, there are two tasks and each task one of two conditions (between blocks). Consequently, there are quite a number of loops/sequences which run conditionally dependent on which level is set in the 'master' loop. Furthermore, each sequence contains a number of sketchpads which are followed by inline scripts to check for fixations to determine what will be presented on the next sketchpad.

I have tried this on two different computers, both running Windows. Each behaves differently, but the root of this appears to be similar.

Computer 1:
The experiment runs fine until a little over half way through. One of the following things happens first, and usually they follow each other.
A: My stimuli start to look like the attached image. To be clear: it's meant to be a face in the centre with one object on each side.
B: The screen greys out and Microsoft's blue spinning wheel makes an unwelcome appearance.

This seems to be a memory issue, as previously indicated by other users on this forum. Upon inspection, pythonw is not responding. Also, the task manager shows two instances running. The first one draws about 25% CPU and 446k of RAM; the second one 0%CPU (?) and 134k RAM (on a 4GB RAM machine).

Troubleshooting / clean up actions
* I had some unlinked logger items. Not completely sure if that makes a difference, but I got rid of them.
* Following a tip I found on this forum, I disable garbage collection and put a gb.collect() script at the end of each sequence.
* Some general decluttering.

All of this worked, as in it suspended the problem until later in the experiment.

Computer 2 (more RAM available):
Appears to run smoother, but I'm running into a psychopy problem (also previously reported by others on this forum). The experiment crashes in the second loop of the second task, usually about 10 out of 40 trials in and has to do with the text that should be presented on the screen (just two letters). Traceback:

Stopped

The experiment did not finish normally for the following reason:

Unexpected error
Details

item-stack: experiment[run].BlockLoop[run].BlockProc[run].Condition[run].Exp_sequence[run].CueingloopU[run].BlockSequence[run].Block_loop[run].CueingSequence[run].GC_target[run]
exception message: exception: access violation reading 0x00000010
time: Tue Jul 11 10:07:33 2017
exception type: WindowsError
Traceback (also in debug window)

  File "C:\OpenSesameC\lib\site-packages\libqtopensesame\misc\process.py", line 140, in run
    exp.run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\experiment.py", line 413, in run
    self.items.execute(self.var.start)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 91, in execute
    self.run(name)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\sequence.py", line 51, in run
    self.experiment.items.run(_item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\loop.py", line 337, in run
    self.experiment.items.execute(self._item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 91, in execute
    self.run(name)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\sequence.py", line 51, in run
    self.experiment.items.run(_item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\loop.py", line 337, in run
    self.experiment.items.execute(self._item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 91, in execute
    self.run(name)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\sequence.py", line 51, in run
    self.experiment.items.run(_item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\loop.py", line 337, in run
    self.experiment.items.execute(self._item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 91, in execute
    self.run(name)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\sequence.py", line 51, in run
    self.experiment.items.run(_item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\loop.py", line 337, in run
    self.experiment.items.execute(self._item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 91, in execute
    self.run(name)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\sequence.py", line 51, in run
    self.experiment.items.run(_item)
  File "C:\OpenSesameC\lib\site-packages\libopensesame\item_store.py", line 106, in run
    self[name].run()
  File "C:\OpenSesameC\lib\site-packages\libopensesame\sketchpad.py", line 124, in run
    self._t0 = self.set_item_onset(self.canvas.show())
  File "C:\OpenSesameC\lib\site-packages\openexp\_canvas\psycho.py", line 144, in show
    stim.draw()
  File "C:\OpenSesameC\lib\site-packages\psychopy\visual\text.py", line 739, in draw
    self._pygletTextObj.draw()
  File "_build/bdist.macosx-10.5-x86_64/egg/pyglet/font/__init__.py", line 565, in draw
    self._layout.draw()
  File "_build/bdist.macosx-10.5-x86_64/egg/pyglet/text/layout.py", line 852, in draw
    self.batch.draw()
  File "_build/bdist.macosx-10.5-x86_64/egg/pyglet/graphics/__init__.py", line 554, in draw
    func()
  File "_build/bdist.macosx-10.5-x86_64/egg/pyglet/graphics/__init__.py", line 486, in 
    (lambda d, m: lambda: d.draw(m))(domain, mode))
  File "_build/bdist.macosx-10.5-x86_64/egg/pyglet/graphics/vertexdomain.py", line 313, in draw
    glDrawArrays(mode, starts[0], sizes[0])
WindowsError: exception: access violation reading 0x00000010

Troubleshooting
I tried the things suggested in this post: http://forum.cogsci.nl/index.php?p=/discussion/2676/windows-error-access-violation-crash. Including explicitly deleting canvas items in the sketchpad.py script, and upgrading psychopy. Pyglet was already the latest version.
The Legacy backend seems to be more sluggish and I also get the previous crash (pythonw not responding + blue spinning wheel galore). Also, it doesn't handle switching between the experiment screen and the calibration screen well plus I prefer a dual screen set-up, so I prefer avoiding this.

Is there anything else I could try? Maybe others ran into similar issues and managed to resolve this?

Apologies for the lengthy post.
tl;dr: I have a mixture of Windows processing and Psychopy issues, help please.

IMG_2089.JPG 72.8K

Comments

  • sebastiaansebastiaan Posts: 2,811

    Hi,

    I suspect that these are all manifestations of a bug (a memory leak) in PyGlet or PyOpenGl, which are used by PsychoPy. This happens sometimes, and when it does, there's little that you can do about it.

    But I was just reading on the PsychoPy forum that PsychoPy standalone is now bundled with a version of PyGlet in which this bug is fixed. If that's true, that might be something for OpenSesame as well. @JonPeirce Is that correct?

    Cheers,
    Sebastiaan

    Thanked by 1cesco

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • sebastiaansebastiaan Posts: 2,811
    edited July 21

    @cesco I updated PyGlet to 1.3.0b1 in the latest prerelease of OpenSesame 3.1.8 (a1-py2.7-win32-2). Could you try whether this resolves the issue?

    Thanked by 1cesco

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • cescocesco Posts: 26

    Thank you Sebastiaan, both posts were really helpful. In the end, I made the experiment work by splitting the whole session into two separate halves, which works fine but it's far from perfect / clean. Either way, I'll give PyGlet 1.3.0b1 a go and will report back here!

  • cescocesco Posts: 26

    @Sebastiaan, negative.

    Things do run much smoother now and the problems with the screen going idle and image looking scrambled appear to have disappeared now. By monitoring the system's performance it is easy to see that gb.collect() helps a lot too.

    I tested the experiment with the prerelease you linked twice today. The first time was perfect. The second time I got the same WindowsError with about 10% of trials remaining.

    Oddly enough in my case, it appears to be related to text rendering in Pyglet. Since I only have two target letters, do you think it would make sense to replace these by images of the letters?

  • cescocesco Posts: 26

    Oddly enough in my case, it appears to be related to text rendering in Pyglet. Since I only have two target letters, do you think it would make sense to replace these by images of the letters?

    For future reference (i.e. if someone with the same problem uses the search function): Tried this, no luck.

  • sebastiaansebastiaan Posts: 2,811

    That's unfortunate. Based on this post by @JonPeirce I was hoping that updating PyGlet would resolve the issue.

    Is it an option to switch to another backend? This issue is specific to PsychoPy. I haven't seen or heard from it happening with Expyriment or the legacy backend.

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • cescocesco Posts: 26

    It took me a while to report back here, as I didn't want to draw any conclusions based on potential lucky breaks (even in debugging sample-size matters). Anyway, the experiment is working now, without crashing.

    As always, in case it helps anyone in the future, here's a list of what I've changed. Keep in mind that I did this during the weekend. Working from home is one thing but taking the eye-tracker home to check every little change properly was one step too far for me. So, I implemented these in one go and I fully realise that a number of these are just superstition.

    • Got the pre-release version mentioned above, but copied my edited Pygaze scripts back in.
    • Amended sketchpad.py so that it explicitly deletes canvas items.
    • gc.collect() after every block. (Technically, after every half-block, as there are self-paced breaks there.
    • Carefully raised the priority of the pythonw process in Windows. I feel like this had quite the impact I was looking for.
    • I got rid of loops-in-loops-in-loops-in-loops. I don't think that this matters, but at least it's more pleasing to the eye. Thus, the second, trouble-making, task now consists of two separate, unlinked loops of 40 trials. It used to be 10 repeats of a 8-item loop with a break thrown in after 40 trials. The crash almost always happened in the first repeat after the break. So even if this is one of those superstitious decisions, I stand by it because it works :)
    • Some general clean up in my code. Which is always a good idea.

    I only get one error that exits the experiment at the very end; saying that it could not save data to iViewX. However, all the SMI data is there, the PyGaze log is there, and the OpenSesame log is there, so I am going to ignore that one.

    Thanks again for all the pointers!

Sign In or Register to comment.