| Reference | Downloads | Github

waitBlanking=False disables time tracking for win.flip()

So I’m using a linux machine and scripts running on this PC usually have visual.window set with waitBlanking=False to fix the double-the-time per frame issue that occurs on Ubuntu.

I recently needed to track the flip time in a particular script but in doing so, it produces a NaN/None value. Took me a while to locate the source of this problem. Only when setting waitBlanking=True will then a value be generated. Any clue as to how to get this to work?

The following codes are enough to replicate this error:

from psychopy import visual, event, core, data

window =visual.Window(size=(1152,864), screen = 0, allowGUI=False,
bitsMode=None, units='pix', waitBlanking=False, winType='pyglet')

gaze_dot =visual.GratingStim(window,tex=None, mask="gauss", 
                             pos=(0,0 ),size=(80,80),color='green', 

for x in range(200):
fliptime = window.flip()
print fliptime

Ah, yes, the code to return the flip time apparently only occurs if waitBlanking is True. We could change that without causing any damage to existing code I think (the logic would be that flip times on most machines are only accurate with waitBlanking turned on but this is a good example of not doing that).


  • you could change the Window.flip() function yourself in your copy of psychopy so that return now is always executed
  • you could also workaround this by setting win.recordFrameInervals = True (as in the time by frames demo) and then printing out win.frameIntervals. That setting and attribute are valid even with waitBlanking=False

Thanks Jon. I take it that there is no other way to record the win.flip() based on the core.clock system rather than win.frameIntervals method (which prints out a list of 0.166… [ms per frame for my 60hz monitor])? The downside to using win.recordFrameIntervals is that it doesn’t account for time of the experiment/script when no flips were executed, which is what I primarily needed - to be able to track real time when a flip occured.

Also, I tried changing the win.flip function via the source code to the following but I’m still getting None value when calling for the time:

    #If self.waitBlanking is True, then return the time that
    # GL.glFinish() returned, set as the 'now' variable. Otherwise
    # return None as before
    if self.waitBlanking is True:
        return now
        return now