JavaScript Error, sometimes, and over different browsers

URL of experiment: https://run.pavlovia.org/PaulOrav/state-empathy-and-visual-perspective-takine/

Description of the problem: I am assisting a student with their project. They were able to upload a working version to Pavlovia, however some participants are now getting the Unspecified JavaScript Error. The issue is it seems random, and occurs across browsers.

The student can run it in Chrome, Brave and IE. Whilst on my PC I can only get it to run on Firefox.

Any help or ideas would be great.

Take a look in the Browser console to see what kind of error message it shows. You can invoke the console on Firefox and Chrome by pressing F12

This is what I get from the console:

core-2020.2.js:1822 null
window.onerror @ core-2020.2.js:1822
log4javascript.min.js:1
FATAL unknown | null
BrowserConsoleAppender.append @ log4javascript.min.js:1
Failed to load resource: the server responded with a status of 404 ()

Aha! This line is interesting…

Failed to load resource: the server responded with a status of 404 ()

It suggests that some of your resources couldn’t be downloaded. Next you could look in the network tab to see which one it is.

I ran it again to try and look at the network tab, it still doesn’t run however that 404 error has disappeared.

It now just has:

core-2020.2.js:1822 null
window.onerror @ core-2020.2.js:1822
error (async)
_captureErrors @ core-2020.2.js:1820
PsychoJS @ core-2020.2.js:1516
(anonymous) @ Final version experiment.js:17
log4javascript.min.js:1 FATAL unknown | null
BrowserConsoleAppender.append @ log4javascript.min.js:1
Appender.doAppend @ log4javascript.min.js:1
Logger.callAppenders @ log4javascript.min.js:1
Logger.log @ log4javascript.min.js:1
fatal @ log4javascript.min.js:1
dialog @ core-2020.2.js:1151
window.onerror @ core-2020.2.js:1823
error (async)
_captureErrors @ core-2020.2.js:1820
PsychoJS @ core-2020.2.js:1516
(anonymous) @ Final version experiment.js:17

Perhaps some resources are not always downloaded and so only sometimes trigger an error?

With regard to the other issues, maybe add some console.log statements to see where it goes wrong?

I think you might be right as it has now gone down to 2 errors with no changes.

log4javascript.min.js:formatted:1635 FATAL unknown | null
BrowserConsoleAppender.append @ log4javascript.min.js:formatted:1635

That error sends me to this line

console[consoleMethodName].apply(console, formattedMessage)

Which just seems to be part of the script to create the alert message.

Yep. I guess that part of the system for showing the error encountered an error :slight_smile:

Before giving you further advice, let me inventorize the background for a bit: have you tried adding console.log statements to your script? I tend to a truckload of those to see what happening. It’s also a nice way to pinpoint where the error is (between the last console.log and the next one you’d expect but didn’t appear). Here are some pointers about console.log and the browser console: https://www.psychopy.org/online/fromBuilder.html#finding-the-problem

I’ll get the student to add some console.log statements and reupload. I have now had a second student come to me with the same error, I wonder if it’s something wrong with how we’re getting them to add the experiment to Pavlovia? Though I am getting them to follow the YouTube tutorial uploaded by PsychoPy.

Do the students build the experiments from scratch? Or is it more like you’ve built a base experiment that they are modifying?

They’re building them from scratch. They’re mostly using keyboards, images and text with additional coding so they “should” sync quite easily.

If I got a penny each time something didn’t work even though it should, I’d built much more buggy software :slight_smile:

Please keep me in the loop; I’d love to know what they found. That knowledge could also be valuable in improving our debugging guidelines