psychopy.org | Reference | Downloads | Github

Pilot experiment stuck in "initialising the experiment"

URL of experiment: https://gitlab.pavlovia.org/VinVen/visualmemory

Description of the problem: I uploaded the experiment to Pavlovia and set activity to Piloting. When starting the Pilot, the browser screen remains fixed in the “initialising the experiment” message. The experiment runs without issues on Psychopy3 (version 2020.1.2, running on Macbook OS High Sierra). I tried debugging the .js script using Chrome’s debugging tool, which returned errors, but I could not get wiser from those (I am new to JavaScript, as part of running online experiments).

Kind regards,
Vincent.

Can you share the errors you’re getting?

Uneducated guess is that it might have to do with the sheer number of images you’re trying to load at once (hundreds), but without knowing more about the errors you’re seeing I don’t know.

Dear Jonathan,

thanks for your very quick reply, on a Sunday afternoon. Attached is a screenshot of the js debugger in Chrome. Apologies if this is not informative enough, I am new to js debugging, so please let me know if you require something else for information.

Kind regards,

Vincent.

Well, the good news is that this error message isn’t related to your experiment, that error is for the repository page itself. If you launched the experiment and opened the console on that page, then you would see any javascript errors that were from the experiment code. To my surprise, Pavlovia didn’t do what it usually does in these cases and pop up an error window. However, when I checked the console from the actual experiment page, I got this:

Much more informative. It’s getting stuck because of a simple syntax error.

Looking through that bit of code, it seems to be a custom component? Custom components don’t handle library imports right now, so importing os, random, and time like they’re python libraries just won’t work.

Looking at the actual code, you don’t need the os import at all (among other things that looks like it was partly to fix something on the Python side that I addressed recently: Working directory change with 2020.1 and later?).

Every instance of “time” will need to be replaced with either Date.now() or a util.Clock object, both of which are built in to this experiment already (you will need to do this several times, I see the time library is invoked at several points throughout the experiment).

“random.shuffle” needs to be replaced. Now, by default the way PsychoPy would like you to do this involves using a TrialHandler or just setting it up in the builder. If that won’t work for you, you can simply roll your own shuffle function:

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}

This is a standard JavaScript shuffle function that you can find with some cursory googling. The Math library is built in, no extra imports required.

EDIT: And I should add, this is how to fix it by directly modifying the javascript. It’s probably the fastest way to go. There are possibly more elegant solutions you could pursue within the builder, but this is the one I’m most confident will just work.

Dear Jonathan,

thanks so much for your elaborate and informative answer! I will get to work on implementing the suggested changes as soon as possible.

Kind regards,

Vincent.