I have read a couple of questions that tackle the same issue, but unfortunately, i couldn’ t solve my my problem. This major issue for me after going far in using defold. I hope you can assist me.
I have a desktop with i7 & GTX680, and i have a laptop with i3 & Intel HD Graphics (not sure what series, but its kinda old 2010). When i run my game on the desktop, its fast and everything is works great. When i run it on my laptop, its slow, and the jumping reaches the ceiling of my level, and most importantly, collision doesn’t work properly as i keep falling through it.
Please note that FPS is set to 60 and variable_dt is checked. Also, i have tried to install the latest driver on my laptop, but same issue. I even tried to deploy on my mobile, but i had the same issues.
Desktop
Laptop
First, i tried to compare to dt variable. In desktop, i got an average value of 0.016499999910593, and in the laptop i got an average value of 0.050044998526573.
Second, i tried to run the debugger which displays several statistics on screen. For the desktop, i got a locked 17 fps, but for the laptop, i got an average of 40 fps.
Third, i ran the web profiler. Below are my results:
Just looking at the profiler it seems that the majority of the time in the frame is spent in the physics engine updating the simulation. Are you using a lot of physics objects for collision? That might explain why the performance is fine on your desktop but not on your laptop.
I don’t think the graphics are the problem but the CPU. Actually, looking a bit closer your render script does take a long time on your laptop.
Your rendering doesn’t seem to take a lot of time, but how many draw calls do you have?
What does seem to take a lot of time is the physics, the games I have worked on have barely used any physics so the only pointer I have here is to try to use static objects as opposed to Dynamic and Kinematic, of course try to keep collision objects to a minimum.
It does look like you do quite a bit in update loops, for this kind of game it is inevitable, but try to update positions and such with the engine and C (go.animate) and not the in LUA as mentioned in the first link of this post.
Did you profile using the latest update for Defold Editor 2? There was a bug before that with the profiler.
The Vsync is waiting for a long time. Anyone got any explanation why?
Seems that physics is taking long time. Are you using tiles or game objects that masquerade as tiles?
Same with the GameObject context. There’s some serious processing going in there. Are you using a camera component or are you moving the world around the hero?
The values seem somewhat similar between desktop and laptop except the point below.
On the laptop due to the integrated graphics it’s taking 50+ ms to process the rendering. I think that’s where the huge difference first comes from. I have no idea where to even start optimizing this in Defold.
Thank you guys for the best community ever. Thanks to your info, i was able to optimize my game. I was able to reduce the 137ms to 68ms when there is enemy collision with the player and to 35ms without enemy collision.
Here is what i did:
I noticed that in my level design, i had some outliers tiles to close my level. I think this was the main problem. I immediately removed those tiles and created a 2048x2048 background image, and add that. This gave me a big difference in performance.
I revised my whole code and removed most of the go.get_position() functions, and replaced them with a self property.
whenever there was an arithmetic operations that involves vectors, i altered the code to make it on the x/y coordinate level.
I tried to optimize the code more and remove the msg.post that i use for sprite animation, but i didn’t know how to use go.animate with atlas animation groups.
Doing all that gave me a incredible boost in the performance. It seems we have to start development on weak machine to make sure that conformance is good, otherwise, it maybe too late to start optimizing when going vise versa.
Where does it say 60fps. In the ingame profiler, it says Frame: 16 Max 24, or do you mean the number of messages?
On my desktop PC, i am using Defold Editor 2. In my laptop, i am using Defold Editor 1, because the new editor is heavy and my laptop starts lagging when using it.