It appears that document is not available in edittime...
This throws undefined document:
var canvas2 = document.createElement('canvas')
Unless there is another way to create an offscreen canvas in edittime, I have no other way of rendering textures outside the existing canvas (for caching, image composition etc.).
In runtime, document is accessible.