Performance problem: onEnterFrame random delay


I notice some strange delays on Event.ENTER_FRAME events
To reproduce problem I use latest BunnyMark example, and add these changes:

  1. Remove all bunnys except one
  2. add variable
private var prev_t : Float = 0.0;
  1. change function stage_onEnterFrame to this function
	private function stage_onEnterFrame (event:Event):Void {
		var t:Float = Timer.stamp();
		if ( t - prev_t > 0.03 ) {
			trace(t + " : " + (t - prev_t));
		bunnies[0].x += 0.00;
		prev_t = Timer.stamp();

trace give me this log:

BunnyMark.js:7309 Main.hx:92: 0.3595999999670312 : 0.03969999996479601
BunnyMark.js:7309 Main.hx:92: 3.6907999999821186 : 0.04989999998360872
BunnyMark.js:7309 Main.hx:92: 7.057700000004843 : 0.050500000012107193
BunnyMark.js:7309 Main.hx:92: 8.40659999998752 : 0.03220000001601875
BunnyMark.js:7309 Main.hx:92: 8.44109999993816 : 0.033300000010058284
BunnyMark.js:7309 Main.hx:92: 10.224300000001676 : 0.03359999996609986
BunnyMark.js:7309 Main.hx:92: 13.590699999942444 : 0.05009999999310821

so at random time (each 3-4 seconds) i see delay between calls stage_onEnterFrame much more then 0.015 (standart for FPS=60)

But if comment this line:

		//bunnies[0].x += 0.00;

then no random delays in log, each delay between calls of stage_onEnterFrame about 0.015 seconds.

What is it? Is some one can reproduce this?

I use Windows10, Chrome 64.0.3282.140, lime [6.1.0], openfl [7.1.1].


Is that in release? debug would not be useful for a test like that.
Else i would guess its something in the background like maybe GarbageCollector!?


I test it in Release and Debug - no matter.
All other tabs in Chrome was closed. No other programs which load CPU.
Chorme “Preformance monitor” at screenshot:


if comment // bunnies[0].x += 0.00;
no CPU usage at all:



If you are in the browser, the time is based on requestAnimationFrame, so we don’t control the timing, but perhaps it is garbage collection


So what may i do to fix this problem?
If it is garbage collection, i can’t do anything?
In real project it behavior give me intermittent animations :frowning:
I don’t know what stuff gave me this problem, but month ago I didn’t notice it.


Instead of using frames to advance your animations, couldnt you use the time(delta) itself as a base.
That way it should be smooth.


What do you mean?
I need change frames and postions for animation. I do it at onEnterFrame event.
Do you know best way for do animations?
Of course postion and frame of sprite is moved by time, i use Timer.stamp() for calculate right position and frame index, but if onEnterFrame event comes with delays, postion and frames are changed with delay too… this is a problem.