I have gotten an error that canvas is not defined sometimes. Of course, nothing will work anyway if it's undefined, so I don't know what this actually solves, other than removing an error from the console.