Closed david-pfx closed 1 year ago
Yes the problem is that redraw
is called when the font is loaded, which sometimes happens before graphics.js
is loaded and parsed. Especially if the files are in the browser cache. But graphics.js
needs the font. Usual chicken and egg problem. I will fix that the clean way :-)
Glad I asked. I was tearing my hair for a while. Makes sense in the bigger picture.
The error is this:
It doesn't happen all the time, and I'm not sure what triggers it. The cause seems to be that you've added a
redraw()
call tofont.js
, but that's ingraphic.js
which is not loaded by the browser until much later. I'm not an expert on browser file loading, but the general idea seems to be that if the browser loads all the files then these functions get hoisted and the order no longer matters. This is during development, so perhaps an error in an intervening file blocks the loading ofgraphic.js
and triggers the error.Once it happens, it's sticky. The only way I found to make it go away is to clear the browser cache. Very annoying.
I'll try shuffling a few files around, see if that helps. I think the real solution is not to rely on the browser, use ES5 require.