[Violation] 'requestAnimationFrame' handler took <N>ms


I am targeting html5 target with Dcanvas, but I am getting this warning in Chrome:

[Violation] 'requestAnimationFrame' handler took <N>ms

[Violation] 'requestAnimationFrame' handler took 1301ms
[Violation] 'requestAnimationFrame' handler took 92ms
[Violation] 'requestAnimationFrame' handler took 310ms
[Violation] 'requestAnimationFrame' handler took 375ms
[Violation] 'requestAnimationFrame' handler took 666ms

Any idea? how to fix this?

I assume that this warning means that the requestAnimationFrame() callback (which is used by OpenFL to render each frame and call Event.ENTER_FRAME listeners) is taking a significantly long time to finish. With this in mind, the fix is to optimize your project’s performance so that frame updates don’t take quite so long.

Thanks @joshtynjala for explanation, can you suggest how would I diagnose and profile so that I find where the exact slowness at my openFL project? is there any recommended approach/profiling library as we use haxe?

Thanks again :slight_smile:

I haven’t needed to do much in the way of performance profiling yet, but I’ve heard good things about hxScout.


Browsers itself have tools for profiling.

Is there any particular reason that you need to use -Dcanvas? Your project would probably run faster if it could be hardware accelerated.

Thanks @andrew911
@joshtynjala I have this concern HTML5, black area when using Dwebgl , what do you think about it?

Reduce the size of your assets and optimize parent child hierarchy is the best thing to do here. You probably have some bitmap that is oversized. Also, you want to decrease the number of your logs. Logs are essentially really slow and if you have some going in the loop removing them would be a good starting point.

1 Like