Random Stuttering

Monkey Forums/Monkey Programming/Random Stuttering

Chroma(Posted 2013) [#1]
Does anyone else notice that about 30% of the time, a monkey app will start in a sort of "stuttering mode" where movement is jerky. But run it again and it's smooth? This happens on my laptop and desktop. It happens with Monkey69 and the latest version.

Even when it's smooth there a slight stutter every several seconds or so.


Paul - Taiphoz(Posted 2013) [#2]
I have seen it on html5 and on my phone think I'm on 70-6? something ..

I'v not really looked into it or given it much thought but it could be the loading of assets and memory getting sorted out on a first run, and with it running better the second time as a result of the assets being cached.

not sure tho that's a guess.


Gerry Quinn(Posted 2013) [#3]
Good test would be: does it happen on apps with minimal assets?

Also, consider putting something recognisable, e.g. Cls( 255, 0, 255 ) in OnLoading().


Chroma(Posted 2013) [#4]
I looked through the forums and it looks like this has come up many times. I was storing my sprites in a List and changed it to a Stack and that seemed to help initially but the stuttering is back. Obviously it has to do with the timing. Does anyone have a fix for this?


therevills(Posted 2013) [#5]
What targets are you seeing this on?

It might be the loading the images onto the GPU, try caching them... and if that helps it might suggest the Monkey isnt releasing them correctly.

To cache them, once you have loaded the images draw them off-screen, that will load them onto the GPU.


Sammy(Posted 2013) [#6]
I am getting this to a certain extent too but this may be down to my in-experience with using delta timing. So I can't say for sure.

When it does happen it's mainly GLFW and within the first couple of minutes of gameplay.


OvineByDesign(Posted 2013) [#7]
I get the same here, stuttering every so often. I setup a test game that just draws rectangles scrolling across the screen so no assets to speak of.

The only way I have go it to work smoothly is to make it fixed step by putting the update loop inside of onrender. 3 rectangles being drawn shouldnt tax my I7 pc but it does. (Ive tested with IOS, GLFW and android )

/Stu


Gerry Quinn(Posted 2013) [#8]
That sounds as if rendering slows down occasionally for some reason, causing multiple calls to OnUpdate(). Having OnUpdate() check the time passed should help.


Chroma(Posted 2013) [#9]
Anyone know exactly where the timing code is for OnUpdate? I can take a look at that see if I can fix it. Or is it dropping a frame here and there in OnRender? Hmm...


therevills(Posted 2013) [#10]
The timing code is in the native game files (eg. flashgame.as, glfwgame.cpp) and mostly it looks like this:
		for( updates=0;updates<4;++updates ){
			_nextUpdate+=_updatePeriod;
			
			UpdateGame();
			if( !_updateRate  || _suspended ) break;
			
			if( _nextUpdate-((new Date).getTime())>0 ) break;
		}
		
		RenderGame();


Maybe look at the bouncy aliens and add the fps counters both for update and render to find out the issue... I havent actually seen it myself.


Chroma(Posted 2013) [#11]
How come the OnRender() runs at the rate set by SetUpdateRate? I thought OnRender() runs as fast as it can and isn't coupled to OnUpdate()!!


Gerry Quinn(Posted 2013) [#12]
It runs at the update rate, and failing that, as fast as it can.

Usually OnRender() takes longer than anything else, so it tends to be the bottleneck.