My online experiment abruptly halts on the way

URL of experiment: online experiment URL

Description of the problem:

I set up a self-paced reading (in Korean) online experiment using psychopy v2020.1.3. In the experiment, a participant should read sentences in the self-paced way and rate them on the scale of 1 to 5 using a slider (you click one of the intersection points on the slider bar to give it a score).

It perfectly worked both locally and on pavlovia at least with my computer and with my colleague’s computer. However, when I let four participants run the experiment on the URL, all of them told my colleague without exception that the experiment runs fine at first, but it abruptly halts at some point showing the message “Initialising the experiment” and stuck. Some stopped only after a few trials, while others stopped after more than 70 percents of trials. It seems like the halting point is random.

Today, one of my participants reported that the screen got darker gradually at some point and ended up throwing “Initialising the experiment” message in the middle of the experiment. However, the funniest thing is that because I have never seen the error on my computer in person, I can’t give you the error screen shot!

I asked participants to use Chrome browser, and I doubt that it is a browser issue if they followed the request. I’m not sure, but I suspect that two code components for self-paced reading in the psychopy exp file might cause the trouble. I have never experienced this kind of problems when running experiments without code components in it on internet.

My psychopy experiment file:

psychopy exp file

JS codes for self-paced reading:

Begin experiment*

thisExp = psychoJS.experiment;
win = psychoJS.window;

Begin routine*

sentenceList = sen_segment.split("*");
wordNumber = (- 1);

Each frame*

var _pj;

function replaceWithdash(textList, currentWordNumber) {
    var index, result, word;
    result = "";
    index = 0;
    while ((index < textList.length)) {
        word = textList[index];
        if ((index !== currentWordNumber)) {
            result = ((result + ("_".repeat(word.length))) + "__");
        } else {
            result = (" " + (result + word) + " ");
        }
        index = (index + 1);
    }
    return result;
}

function _pj_snippets(container) {
    function in_es6(left, right) {
        if (((right instanceof Array) || ((typeof right) === "string"))) {
            return (right.indexOf(left) > (- 1));
        } else {
            if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                return right.has(left);
            } else {
                return (left in right);
            }
        }
    }
    container["in_es6"] = in_es6;
    return container;
}
_pj = {};
_pj_snippets(_pj);
stimuli.text = replaceWithdash(sentenceList, wordNumber);
keypresses = psychoJS.eventManager.getKeys();
if ((keypresses.length > 0)) {
    if (_pj.in_es6("space", keypresses)) {
        thisResponseTime = t;
        wordNumber = (wordNumber + 1);
        if ((wordNumber < sentenceList.length)) {
            if ((wordNumber === 0)) {
                timeOfLastResponse = 0;
            }
            thisExp.addData(("IRI_" + wordNumber.toString()), (thisResponseTime - timeOfLastResponse));
            timeOfLastResponse = thisResponseTime;
            stimuli_2.text = replaceWithdash(sentenceList, wordNumber);
        } else {
            continueRoutine = false;
        }
    } else {
        if (_pj.in_es6("escape", keypresses)) {
            psychoJS.quit();
        }
    }
}

Text component for sentence stimuli:

It will be truly appreciated if you give me any helpful hints to solve this strange problem.

Best,
Galaxy

I wonder if this is a memory issue (2020.2 is generally better than 2020.1 for them). Do you have anything updating every frame?

Two JS code components for self-paced reading in my experiment have code scripts for each frame. However, nothing else is set to be updated every frame. Sentence stimuli are set to be presented on every repeat as you can see the screen shot. For you information, even when I set them to the constant mode, things didn’t change. If the memory issue causes the problem, should I upgrade psychopy to v.2020.2? Thank you very much for advice!

I can see that stimuli2 gets updated when the space bar is pressed but I can’t see the code for updating stimuli. To keep memory issues to a minimum it should only get updated when the display changes (eg when a key is pressed) and not every frame regardless of whether there has been a change or not

If then, how should I modify the code (or the builder component) for the stimuli to get updated only when the change of their display occurs? Unfortunately, I’m quite new to python, so it’s very tricky to figure out where the trouble is brought about in the code. Thank you very much for your advice!

Is the each frame code auto translated? If so, please could you show the Python code? As I said, I can’t see a reference to your stimuli text component, only stimuli_2.

Oh, I’m sorry. I made a typo. It should be “stimuli”, not “stimuli_2.” But It seems like it wasn’t a crucial issue. Auto translation from python to Java didn’t work for the python code for Begin routine. So I borrowed JS code from this reference post. That’s why the function definition of replaceWithdash is located at each frame section in JS version.

python code for stimuli: Begin routine

sentenceList = sen_segment.split("*") 
wordNumber = -1

def replaceWithdash(textList, currentWordNumber):     
    dashSentence = ''
    for index, word in enumerate(textList):
        if index != currentWordNumber: 
            dashSentence = dashSentence + "-" * len(word) + "--" 
        else:
            dashSentence = " " + dashSentence + word + " " 
    return dashSentence 

stimuli.text = replaceWithdash(sentenceList, wordNumber)  

python code for stimuli: Each frame

keypresses = event.getKeys() # returns a list of keypresses 

if len(keypresses) > 0:
    if 'space' in keypresses:        
        thisResponseTime = t 
        wordNumber = wordNumber + 1 
        if wordNumber < len(sentenceList): 
            if wordNumber == 0:
                timeOfLastResponse = 0 
            thisExp.addData('IRI_' + str(wordNumber), thisResponseTime - timeOfLastResponse) 
            timeOfLastResponse = thisResponseTime 
            stimuli.text = replaceWithdash(sentenceList, wordNumber) 
        else: 
            continueRoutine = False 
    elif 'escape' in keypresses: 
        core.quit() 

JS code for stimuli: Begin experiment

thisExp = psychoJS.experiment;
win = psychoJS.window;

JS code for stimuli: Begin routine

sentenceList = sen_segment.split("*");
wordNumber = (- 1);

JS code for stimuli: Each frame

var _pj;

function replaceWithdash(textList, currentWordNumber) {
    var index, result, word;
    result = "";
    index = 0;
    while ((index < textList.length)) {
        word = textList[index];
        if ((index !== currentWordNumber)) {
            result = ((result + ("_".repeat(word.length))) + "__");
        } else {
            result = (" " + (result + word) + " ");
        }
        index = (index + 1);
    }
    return result;
}

function _pj_snippets(container) {
    function in_es6(left, right) {
        if (((right instanceof Array) || ((typeof right) === "string"))) {
            return (right.indexOf(left) > (- 1));
        } else {
            if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                return right.has(left);
            } else {
                return (left in right);
            }
        }
    }
    container["in_es6"] = in_es6;
    return container;
}
_pj = {};
_pj_snippets(_pj);
stimuli.text = replaceWithdash(sentenceList, wordNumber);
keypresses = psychoJS.eventManager.getKeys();
if ((keypresses.length > 0)) {
    if (_pj.in_es6("space", keypresses)) {
        thisResponseTime = t;
        wordNumber = (wordNumber + 1);
        if ((wordNumber < sentenceList.length)) {
            if ((wordNumber === 0)) {
                timeOfLastResponse = 0;
            }
            thisExp.addData(("IRI_" + wordNumber.toString()), (thisResponseTime - timeOfLastResponse));
            timeOfLastResponse = thisResponseTime;
            stimuli.text = replaceWithdash(sentenceList, wordNumber);
        } else {
            continueRoutine = false;
        }
    } else {
        if (_pj.in_es6("escape", keypresses)) {
            psychoJS.quit();
        }
    }
}