Isolated it. This bug occurs when you have two different pyglet windows of two different sizes. Oddly, objects in each window seem to scale to the other window’s size. I’ve tested this a bunch of different ways using screensAndWindows.py. Let me lay out some things in fine detail.
Here’s how the windows are being set up:
if True: # use two positions on one screen
winL = visual.Window(size=[600, 450], pos=[100, 200], screen=0,
allowGUI=False)
winR = visual.Window(size=[400, 300], pos=[600, 200], screen=0,
allowGUI=False)
Note winL is bigger than winR.
Draw everything in winR and winR is flipped before anything is drawn to winL, then draw everything in winL and flip winL: No problems at all. Similarly, if you do all of winL and then all of winR, no problems. Order of creation doesn’t seem to matter.
Draw everything in winR, draw anything in winL, and then flip winR, then draw everything else in winL and flip winL: Everything drawn in winL AFTER winR is flipped is scaled to winR’s size, i.e., shrunk. Strangely, the thing drawn before winR is flipped is correctly scaled to winL! If you flip winR and winL here (draw everything to winL, draw anything from winR, then flip winL), you get the same effect in winR: Everything draw before winL is flipped is correctly scaled, everything drawn after is expanded to winL’s scale.
Draw everything to winL AND everything in winR, then flip winL and then flip winR: They swap scales. Everything drawn in winL is scaled to winR and vice-versa.
Draw nothing in winR, draw everything in winL, flip winL, then flip winR: Everything in winL scales to winR after the first flip. This one gets better:
As the last one, but wait 60 frames and then start drawing stuff to winR and flipping it after winL has flipped: Both of them are fine again! It resizes everything in winL to its proper scale, and starts behaving like the first setup I mentioned, where you draw everything in a window and flip it and then draw everything in the other window and flip it.
Doing literally anything with waitBlanking: No effect at all.
@jon or @mdc, do you have any ideas about how to fix this? I at least understand what’s happening now, kind of, but it’s very hard to work around and I have no clue where this could be originating from in the code. PsychoPy’s window class? Pyglet window? Pyglet canvas? Something deeper? Also, with regard to my particular program (PyHab), this seems to also happen when flipping a window with a paused movie object in it. Drawing a paused movie object is like drawing nothing to the window, is basically what’s going on. I might be able to draw some kind of invisible dummy object to keep it from doing this as a temporary fix (this does work, just draw something the color of the background onto the background), but I’d love to develop a proper one.