Description of the problem: I am investigating the delays in recorded key response times of an experiment in my lab. I have not yet been able to reproduce the recorded delays, however, I am running into the issue that on some machines the experiment slows down / crashes, whereas it seems to run perfectly fine on others. I would like to understand why the experiment is crashing and would like to ask for recommendations for how to profile the performance of a PsychoJS experiment hosted on Pavlovia.
Let me first detail the experimental setup. I have compiled the PsychoJS experiment using PsychoPy v2022.2.5 and am piloting it on Pavlovia. I describe the experiment as potentially graphics-intensive because it has a routine that displays at most around 250 visual.Polygon dots on the screen. I have simplified the code for readability, but these are initialized like:
// Create dots
const dots = [];
const n = 1000;
for (let i = 0; i < n; i++) {
dots[i] = new visual.Polygon({
win: psychoJS.window,
name: 'polygon',
edges: 99,
size: [0.002, 0.002],
ori: 0,
pos: [0, 0],
lineWidth: 1,
lineColor: pointColor,
fillColor: pointColor,
opacity: 1,
depth: 0,
interpolate: true,
});
dots[i].setAutoDraw(false);
}
And updated each frame like:
// Update position of dots
for (let i = 0; i < n; i++) {
const degree = Math.random() * 360;
const posX = Math.random() * radiusX * Math.cos(degree);
const posY = Math.random() * radiusY * Math.sin(degree);
dots[i].setPos([posX, posY]);
dots[i].setAutoDraw(true);
}
I ran the experiment on two different machines:
iMac (21.5-inch, Late 2015)
Processor: Intel(R) Core™ i5 @ 1.6 GHz 2 cores
Memory: 8 GB 1867 MHz DDR3
Graphics: Intel(R) HD Graphics 6000 1536 MB
Browser: Chrome
Windows 10 PC
Processor: Intel(R) Core™ i5-4750 CPU @ 3.40GHz 4 cores
Memory: 8GB 1600 MHz DDR3
Graphics: Intel(R) HD Graphics 4600
Browser: Firefox
The experiment slows down / crashes about twenty or thirty minutes on the Mac machine whereas it runs completely fine on the Windows machine. It is important to note that while both machines have similar memory and graphics capabilities, the higher clock speed and additional cores of the Windows machine give it an advantage in processing power. This could be one reason why the experiment performs as desired on the Windows machine but crashes on the Mac machine.
On the Mac machine, sometimes PsychoJS gives me the following error:
Which tells me that the experiment might be requesting to allocate too much memory.
Do you have any suggestions on how to profile the performance of a PsychoJS experiment hosted on Pavlovia? In particular, I would like to understand how to track down the allocation size overflow error; should I just be using the JavaScript console / performance tools for the browsers we are running the experiment on? Are there any other tools or considerations I should take into account when trying to profile a PsychoJS experiment hosted on Pavlovia?