psychopy.org | Reference | Downloads | Github

TypeError: Cannot read properties of null (reading 'width')

Hello!

I am trying to get an experiment online, but continue to get the following error:

TypeError: Cannot read properties of null (reading ‘width’)

which for a split second reads

TypeError: Cannot read properties of null (reading ‘uvsfloat32’)

before going back to ‘width’.

This happens after I change from the .append function in python to .push in JS. When opening the console through my browser, it reads the following:

FATAL 14:41:08.384 GUI.dialog psychojs-2021.2.3.js:1257 | {}
BrowserConsoleAppender.append @ log4javascript.js:148

Because of this, I tried removing all python code whereby append was mentioned and including the code ‘Array.prototype.append = .push’ in the begin experiment tab but the problem persists…

Is anyone able to help with getting this to run? :slight_smile:

Here is a link to the gitlab:

What version of PsychoPy are you using? The latest versions automatically translate append to push and will crash if you add Array.prototype.append = .push in Begin Experiment.

2021.2.3

Yes, the experiment failed to initalise with the array.prototype.append = .push. included…

However, without editing anything of the JS and keeping the auto translation from python (and thus it reads .append on both sides), it reads * TypeError: instr_Clicked.append is not a function .

When changing manually the .append to .push on the JS side, it gives the * TypeError: Cannot read properties of null (reading ‘width’)

If you are using 2021.2.3 then you should be able to make any edit on the Python side (e.g. insert and then delete a character) in the Auto translate code component to get the 2021.2 translator to spot .append and replace it with .push on the JS side.

Here’s a possible solution to your main issue.

I have replaced the .append with .push on the JS side, and it runs for one trial and then reads the error.

Checked out the linked solution and tried changing the mask files to separate ones (as not to use the same one but the masks are still necessary) and the error reads the same

Are you using Ctrl-Shift-R on an incognito tab in Chrome to ensure you run the latest code?

By “the error” I assume you mean the width error.

By replace .append with .push, do you mean that you got the Auto code component to change it automatically?

yes to the running the latest code, the error is indeed the width error, and the replacing of .append with .push is done manually

Look at your properties for instr_target1

Your size is 0.09 set every repeat. Try [0.09,0.09] constant.

Why is instr_setPos set to Both?

Why is if t >= 1: continueRoutine = False in Begin Routine (it does nothing here because t = 0)

You have several psyexp files in the same folder. Pavlovia can only cope with one, so I hope you aren’t trying to use any of the older ones.

So, I changed the size to constant and 0.09, 0.09 (with and without square brackets), still the width error.

In absolute truth, I am not sure why instr_setPos was on both… put it back to auto.

The t >=1: continueRoutine = False has been moved to Each Frame. Nice spot thank you :slight_smile:

If you’d like me to take another look, please could you save and sync your current psyexp file? The js files are currently from one hour ago but the psyexp file is from yesterday.

done!

I have discovered that PsychoJS doesn’t like setting a mask if the image has zero opacity.

Here is a working version of your experiment using instr_target1.setPos([2,2]) instead

https://run.pavlovia.org/vespr/object-foraging

!! Very nicely found, clever solution also :slight_smile: Thank you!