I do believe that this is a flaw in the way PsychoJS is currently designed to work. From the documentation:
By default, PsychoJS downloads from the pavlovia.org server all the resources … at the start of the experiment.
This is indeed true on Pavlovia, but does not work in local debug mode, and in fact, cannot work the way it is currently designed.
One workaround, as mentioned in the documentation, is to load resources manually by editing the .js file of the experiment (found in the html folder). Here is what it looks like in the documentation:
psychoJS.start({
expName,
expInfo,
resources: [
// relative path to index.html
{ name: 'trialTypes_A.xls', path: 'trialTypes_A.xls' },
// absolute path:
{ name: 'trialTypes_B.xls', path: 'http://a.website.org/a.path/trialTypes_B.xls' }
]
});
The drawback to this workaround is that it has to be redone every time the experiment is updated and a new .js file is generated.
Another workaround, mentioned here, is to blank the output folder in experiment settings. The drawback to this workaround is that Pavlovia does not support a blank output folder, so this will only work in local debug mode, and has to be changed back before publishing to Pavlovia. Maintaining two copies of the output folder is also problematic.
The workaround that I am using is simply to fix the bug that causes this problem in the first place, by editing the following PsychoPy code file: [python-package-directory]/psychopy/experiment/flow.py:
@@ -298,7 +298,7 @@
"expInfo: expInfo,\n")
# if we have an html folder then we moved files there so just use that
# if not, then we'll need to list all known resource files
- if not self.exp.htmlFolder:
+ if 1: #not self.exp.htmlFolder:
script.writeIndentedLines("resources: [\n")
script.setIndentLevel(1, relative=True)
code = ""
And then restarting PsychoPy and re-generating the HTML for the experiment.
The way PsychoJS is currently designed, when running on Pavlovia, it makes an API call to get the list of files in the html/resources folder. PsychoJS needs to implement the same API in the local environment for this to ever work.
The silly thing is that PsychoJS already has the capability to pre-load the resources list at compile time, but this is normally turned off - except when the output folder is blank. I am not sure why an API is used on Pavlovia instead of just pre-loading this list, but for now, it makes more sense to simply pre-load the list at compile time in all cases, which is what the simple 1-line code change above does.