Hi all,
I would like to double-check the duration of each frame, by approximating the timestamp when each frame occurs. I have two questions related to this.
Background:
I noticed that in the PsychoJS scheduler code, a timestamp for the next frame flip is recorded when requestAnimationFrame()
is called. FrameDuration appears to be represented by the variable self._lastDelta
; calculated by subtracting the current timestamp from the previous timestamp. Unfortunately, it seems like these timestamp variables are local variables, as I cannot access them directly in a code component.
Question 1) Is there anyway to access the timestamp variables set in Scheduler and store them in a datafile?
Relevant scheduler code:
1.
// store frame delta for `Window.getActualFrameRate()`
2. const lastTimestamp = self._lastTimestamp === undefined ? timestamp : self._lastTimestamp;
3.
4. self._lastDelta = timestamp - lastTimestamp;
5. self._lastTimestamp = timestamp;
6.
7. // render the scene in the window:
8. self._psychoJS.window.render();
9.
10. // request a new frame:
11. requestAnimationFrame(update);
12. };
13.
14. // start the animation:
15. requestAnimationFrame(update);
16. }
17.
My current solution is to run window.requestAnimationFrame in the each frame tab of a code component. This seems to work quite well in approximating the frame duration. However …
Question 2) Would running requestAnimationFrame in the each frame tab of a code component substantially increase the computational strain of running the experiments?
Sorry for the long post and many thanks in advance for any help provided!