Use mouse in different routines causes a long delay

Hi,

Sorry for the long delay. From only a quick look at your code, I can’t pretend to understand all of the logic, but would make a recommendation that you remove anything like this from your code components:

while mouseS3.isPressedIn(S3_) and not (mouseS3.isPressedIn(background_5)):
        continue

In general Python programming terms, a tight loop like this will completely consume your CPU, strangling any other processes. This can cause unexpected delays as other processes (outside PsychoPy) finally jump in and wrest control of the CPU from you. The normal Builder drawing loop (of effectively pausing for a few milliseconds on every screen refresh) allows PsychoPy to be a good citizen and give other processes some access to the CPU.

So the consequences of these sorts of loop are two-fold:

  • you cause bottlenecks for other programs, which can then cause poor performance as they try to compete.
  • you’re also stopping Builder’s natural drawing cycle. If the conditions of your test aren’t met for a while, your effectively pausing all drawing and anything else other than this specific check for mouse presses. This means everything else that Builder normally intends to do on a frequenct cycle (checking the keyboard, redrawing the screen, checking the onset and offset time of stimuli, and so on, is being put on ice.

As a general rule, avoid putting any indefinite loops or pauses in Builder code components, as they disrupt Builder’s inherent event/draw loop cycle.

But I guess that loop is there for some reason, so you need to restructure your code to achieve the same result. Again, I’m not too sure of the required logic here, so can’t give specific advice.