Hi guys, So I'm back with an odd problem. My fb instant game is running very slow on iPhone, be it touch events or gtween events. The game otoh runs smoothly on android devices, even the entry-level ones. So what can the issue be? Thanks.
Ok, so after looking at the forums for some advice, these are the following things I've changed:-
1)I got rid of all touch events in my game. Now there's exactly one touch event added to the stage and I handle all touch events through it, like this
function M:onMouseDown(event)for k, v inpairs(mydata.touchHolder)doif k and v and v:hitTestPoint(event.x, event.y)then
onMouseDown(v, event)endendend
2)Then I'm trying to pool my bitmaps at the start of every scene like this. I'm not sure I'm doing this right as a speed bump has been negligible. So I would really appreciate some advice here.
pool.lua
function pool.create(newO, poolSize, Base)if newO==150thenlocalfunction newObject()local obj = shape.rect(-dx,-dy,fullw+dx+dx,fullh+dy+dy)return obj
end
poolSize = poolSize or16assert(newObject, "A function that returns new objects for the pool is required.")local freeObjects ={}for _ =1, poolSize dotable.insert(freeObjects, newObject())if _==poolSize thenprint("bitmap loaded")local text = TextField.new(mydata.font1, "bitmap loaded")
stage:addChild(text)
text:setPosition(50, 50)endendreturnsetmetatable({
freeObjects = freeObjects,
newObject = newObject
},
poolmt
)elselocalfunction newObject()local obj = Bitmap.new(Base:getTextureRegion(newO))return obj
end
poolSize = poolSize or16assert(newObject, "A function that returns new objects for the pool is required.")local freeObjects ={}for _ =1, poolSize dotable.insert(freeObjects, newObject())if _==poolSize thenprint("bitmap loaded")local text = TextField.new(mydata.font1, "bitmap loaded")
stage:addChild(text)
text:setPosition(50, 50)endendreturnsetmetatable({
freeObjects = freeObjects,
newObject = newObject
},
poolmt
)endendfunction pool:obtain()return #self.freeObjects ==0and self.newObject()ortable.remove(self.freeObjects)endfunction pool:free(obj)assert(obj, "An object to be freed must be passed.")table.insert(self.freeObjects, obj)if obj.reset then obj.reset()endendfunction pool:clear()for k inpairs(self.freeObjects)do
self.freeObjects[k]=nilendendreturn pool
If you are unsure how to interpret the profiler log, post two versions here, one for android and one for iOS. If there is a severe performance issue on iOS, it should appear.
@hgy29 - Sorry for being so late with the reply. I was struggling and failing with getting profiling to work with instant game. I feel like a complete idiot- seems I can do nothing right.
Anyways, if anyone wants to take a look - here' the barebones of the game mechanics. Just game pieces dropping onto a board and looks very jerky on iOS messenger.
@hgy29 - Sorry for being so late with the reply. I was struggling and failing with getting profiling to work with instant game. I feel like a complete idiot- seems I can do nothing right.
Anyways, if anyone wants to take a look - here' the barebones of the game mechanics. Just game pieces dropping onto a board and looks very jerky on iOS messenger.
Sorry that i have no comment for the code but here is some moral support:D
Don't be harsh on yourself so much, this is called a learning curve. Sometimes it is logarithmic and so much difficult, sometimes not. Important thing is to not to quit and always try. Experience can not be gained without a difficulty. When you are depressed always look to the accomplishments that you have achieved, and not focus on your failures. Now show your skills to us Champion:D Note: If this one will not help watch Rocky 1 one more time to give you some quick energy:D
@hgy29 - Sorry for being so late with the reply. I was struggling and failing with getting profiling to work with instant game. I feel like a complete idiot- seems I can do nothing right.
Well don't feel bad about it, honestly I had almost forgotten that I was never able to profile on iOS instant game. It is easy on IG/desktop, and it requires a bit of setup for IG/Android, but I am not sure it is even possible for IG/iOS.
Anyway I tried your code on native iOS, just to get an idea of what consumes CPU. We can see there that there is a lot of function calls per frame, and that could be optimized somehow, but I would be surprised if it was the problem since iOS devices usually have decent CPU power. It could have been canvas size related (retina), but your code doesn't seem to manipulate a lot of pixels.
It could be a general FPS issue: FPS clamped to 30 on iOS/IG, but hard to tell.
Ok, so it turns out that there is no practical way to profile under facebook app webview on iOS. However, I was able to profile a classic HTML5 export running on iOS safari. Unluckily it seems to work rather well on my iPhone (X), so I can't really tell what is supposed to be wrong...
@talis - Thank you so much for your kind words. Means so much to me. No lie , I did watch "Eye of the tiger" on youtube.
@hgy29 - Thank you so much for devoting time to my project. In a way it's a relief to find out that profiling doesn't work on iOS. Makes me feel less of an idiot. Even more of a relief that the game works well on iPhone X. Maybe it's the older models that have this issue with lagging. I guess now I should just concentrate on optimizing all the functions that update per frame and hope for the best.
Again, thank you all for taking an interest in my issue. This forum is the best.
Is your FB system outdated? You can try to update the app's system to the latest version. Please remember to also have a software update on your iPhone. Then clear all apps running in the background and re-launch the game to see if it is still running slow. If it does, then you could try to use related professional ios repair tools such as TunesKit iOS System Recovery. This software could resolve various iOS issues including iPhone and apps running slow.
Comments
1)I got rid of all touch events in my game. Now there's exactly one touch event added to the stage and I handle all touch events through it, like this
pool.lua
levelselectscene.lua
Likes: SinisterSoft
Likes: pm1891
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Anyways, if anyone wants to take a look - here' the barebones of the game mechanics. Just game pieces dropping onto a board and looks very jerky on iOS messenger.
Likes: hgy29
Likes: pm1891
Don't be harsh on yourself so much, this is called a learning curve. Sometimes it is logarithmic and so much difficult, sometimes not. Important thing is to not to quit and always try. Experience can not be gained without a difficulty. When you are depressed always look to the accomplishments that you have achieved, and not focus on your failures.
Now show your skills to us Champion:D
Note: If this one will not help watch Rocky 1 one more time to give you some quick energy:D
Likes: pm1891, plicatibu, jimlev
It is easy on IG/desktop, and it requires a bit of setup for IG/Android, but I am not sure it is even possible for IG/iOS.
Anyway I tried your code on native iOS, just to get an idea of what consumes CPU. We can see there that there is a lot of function calls per frame, and that could be optimized somehow, but I would be surprised if it was the problem since iOS devices usually have decent CPU power. It could have been canvas size related (retina), but your code doesn't seem to manipulate a lot of pixels.
It could be a general FPS issue: FPS clamped to 30 on iOS/IG, but hard to tell.
I will look further and report back.
Likes: Apollo14, MoKaLux, pm1891
Likes: pm1891, SinisterSoft, talis
@talis - Thank you so much for your kind words. Means so much to me. No lie , I did watch "Eye of the tiger" on youtube.
@hgy29 - Thank you so much for devoting time to my project. In a way it's a relief to find out that profiling doesn't work on iOS. Makes me feel less of an idiot. Even more of a relief that the game works well on iPhone X. Maybe it's the older models that have this issue with lagging.
I guess now I should just concentrate on optimizing all the functions that update per frame and hope for the best.
Again, thank you all for taking an interest in my issue. This forum is the best.
Likes: MoKaLux, SinisterSoft, talis