Strange lag on iPhone

Hello,

I have a strange issue on iPhone with the h2d.Graphics. I have a huge level for a car game which is generated with h2d.Graphics. After a few thousands pixel the generated graphic is starting to lag. There is no problem with the car and with the coin tile-animations and there is no any problem on pc.

graphic_lag

Any idea what can be the problem?

You should run the game through Xcode’s profiler to check what’s going on

Ahh yes, I forgot to mention the proper pre conditions :slight_smile:

1, Draw with h2d.Graphics
2, Move the container of the graphics to somewhere x: -5000px
3, Now try to move the container with a tweener or with “function update(d) { container.x–; }”
4, In some reason it’s starting to lag, but it’s no lag because of a performance - animations and other elements are smooth, there is a problem just with the h2d.Graphics

Ok there could be many reasons for mobile Safari to run things slowly and you’re better off using the Safari debugger on a Mac to start with. It should give you some insights on what’s going on since you can connect the desktop Safari to the mobile one to see logs, performances, etc…

Maybe you’re reaching some kind of limits in terms of what the GPU can process per frame. How many triangles/draw calls is there in total ? you can read these values from your hxd.App engine variables

I just tried it with mobile chrome and it’s the same, it looks it’s not a Safari related issue and it looks it affects the ParticleGroup too. There is no problem with FPS and there is no problem with other positions and the strangest part - it happens only when the container’s x position is less than ~5000px (less x position = bigger lagg)

iPhone 6s / Safari
FPS 59-60
drawTriangles 1166
drawCalls 52

iPhone 6s / Chrome
FPS 59-60
drawTriangles 1166
drawCalls 52

Desktop / Chrome / PC
FPS 59-60
drawTriangles 1150
drawCalls 44

(drawTriangles and drawCalls are higher than on desktop because of the 4 extra touch controllers)

I just made one more test - as simple as possible and it’s still strange
http://flashplusplus.net/haxe/demo/iw/test/index.html

var c = new Object(s2d);
c.x = -10000;
var g = new Graphics(c);
g.lineStyle(1, 0xFFFFFF, 1);

for (i in 0...50)
{
	g.drawRect(
		i * 300,
		200 + 200 * Math.cos(i / (Math.PI / 180)),
		250,
		250
	);

	var l = new Bitmap(Res.image.logo.toTile(), c);
	l.tile.scaleToSize(250, 144);
	l.x = i * 300;
	l.y = 200;
}

var t = new Text(FontBuilder.getFont("Arial", 40), s2d);

TweenMax.to(c, 300, {
	x: -c.getSize().width,
	ease: Linear.easeNone,
	onUpdate: function () {
		c.x = c.x;
		t.text = engine.fps + "FPS \n";
		t.text += "Container position: " + c.x;
	}
}).repeat(9999).yoyo(true);