Hello Everyone,
I am new here so I apologise if my topic’s formatting isn’t correct for some reason.
I am coding an experiment in which the stimuli are onscreen until the user makes a keyboard response and there is no set limit on how long they are allowed to wait. I am running into a problem where longer wait times (around 35 seconds) using psychopy.waitKeys() causes the window.flip() function to lag noticeably. It can take almost a full second for the window to refresh which seems to me to indicate that something is seriously amiss. When the wait times are short the win.flip() is faster.
Below I have an example of some code that produces the effect on my machine. As you can see the code is so straightforward there is no obvious reason lag of this kind should be occurring.
I noticed another person (anakhnikian) had a similar topic but they encountered the problem using the builder and no solution has been provided yet.
The computer I am running this on is a Surface Book 2:
- Windows 10 Pro
- i7-8650U CPU @ 1.90GHz
- 16 GB of Ram
- Running PsychoPy v 2020.1.3
Thank you in advance for any insights you can provide.
import psychopy.visual as psyvis
import psychopy.event as psyevent
import psychopy.core as psycore
import psychopy.gui as psygui
timer = psycore.Clock()
win = psyvis.Window(
units = "pix",
size = [400, 400],
fullscr = False,
monitor = None,
color = [1, 1, 1]
)
txt = psyvis.TextStim(
win = win,
text = "wait for about 35 seconds when you see this text then press space",
color = [-1,-1,-1],
height = 40
)
txt.draw()
win.flip()
keys = psyevent.waitKeys(keyList = ['space'])
print(timer.getTime())
win.flip()
print(timer.getTime())
keys = psyevent.waitKeys(keyList = ['space'])
print(timer.getTime())
win.close()
print(timer.getTime())