question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Canvas2D: exceptions during animation

See original GitHub issue

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 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:35 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
WhiteHexagoncommented, May 4, 2020

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

0reactions
mirkoserticcommented, Apr 26, 2022

Closed due to no further interaction.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Canvas 2D Context - W3C
Abstract. This specification defines the 2D Context for the HTML canvas element. The 2D Context provides objects, methods, and properties to ...
Read more >
Objects in HTML5 Canvas leave trail during animation
I am trying to animate the html5 canvas, and I have created objects for each of my elements in it. First of all,...
Read more >
Unwarranted DOM Exception when canvas2D drawImage is ...
Summary: Unwarranted DOM Exception when canvas2D drawImage is called with src rect out. ... In the case of a source rect with a...
Read more >
Jank busting for better rendering performance - web.dev
One of the exceptions to this rule is CSS animations on Chrome for Android (and soon desktop Chrome, though not yet). When possible,...
Read more >
Basic animations - Web APIs | MDN
The requestAnimationFrame method provides a smoother and more efficient way for animating by calling the animation frame when the system is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found