Don't call document.createElement and canvas.createContext on each update for boobs

Create issue
Issue #2 new
David Hayes created an issue

I was running a Chrome profiler and noticed that some of the frames would take a long time, and generally it felt a little jittery. Looking at the code, I found that you were creating new canvas elements for all the Boob objects, and then creating new Context2d objects for them, for each boob, on each frame. The Browser has to garbage collect all the previously created and now ignored canvases, and this accounts for the freezes, and then jittery behaviour.

I have included a patch for the amos2banner.js, I haven’t back ported this into the amos file itself, but it does improve matters a lot. I’m simply checking to see if the boob is already defined, and if so, reset the existing canvas and context, rather than create a whole new one

Comments (1)

  1. David Hayes reporter

    With this fix in place, in amosball, you can safely remove the Boob off command in the loop, and this will run smoother.

  2. Log in to comment