Bytecoder: Canvas2D: exceptions during animation

I am seeing some strange index out of bounds errors whilst animating my scene, but maybe only after around 80,000 iterations. I use something similar to your Kotlin example:

    animationCallback = AnimationFrameCallback { aElapsedTime ->
        //my drawing code
        window.requestAnimationFrame(animationCallback)
    }
    window.requestAnimationFrame(animationCallback)

At first I had it wrapped in a separate class to simplify the calling code and encapsulate some fps timing logic. But now I have stripped everything out, and with just a single println("loop") statement as my drawing logic, I get exceptions after ~80,000 frames.

So I am thinking it could be either the recursion?, or possible something garbage collection based? So I am now just trying to break the recursion pattern to rule that out.

However I can not find support for things like Thread.sleep,wait,notify, or the Concurrent package, or any other mechanism to avoid the recursion…

Sorry to say that I am still using June’19 build because of the UTF-8 issue I have with the new build. So apologies if this has been fixed.

I tried leaving your 2D ball demo running, and it works fine in this version of firefox.

btw I added Binaryen wasm-opt to my build chain, and your hand generated wasm seems very efficient! since it barely shrank the wasm by much at all 😃

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 35 (13 by maintainers)

Most upvoted comments

Awesome, I am very impressed at the speed you added that, I didn’t even get chance to reply to the last comment yet 😃 I give it a try right now since I am currently sat working on that code. [edit: it’s not up on maven central yet, maybe it takes some time?] https://mvnrepository.com/artifact/de.mirkosertic.bytecoder/bytecoder-cli