When during the frame period does the "Each Frame" tab code run?

For online experiments, when during the frame period does the “Each Frame” code run?

My current idea is that once the screen is refreshed and psychoJS receives the signal that the screen has been refreshed, then we immediately execute the code in the each frame tab such that this code will be ran in the very beginning of the frame period.

I believe your interpretation is correct, that this is executed the beggining of a frame (i.e. when the window is flipped) but will tag some team members to check myself here @jon @Michael

The components (code comps or otherwise) all execute their EachFrame code in the order they appear in the Routine.

Thanks for your replies @jon and @Becca.

I was hoping to clarify the following:

Assuming we have all the code in the each frame tab with a runtime that is way less than a frame period, I would like to understand whether or not all this code will be executed immediately. Here is a visual depiction of my understanding. Let the left tick mark be the beginning of frame 0, so here is where the screen refreshes and the right tick mark is the next refresh which is when frame period 1 begins. The up arrow denotes when I believe that all the code in the each frame tab will run given that all this code is super quick in runtime. Is this accurate?


Yes, that’s correct