Slow physics on iOS

Hi forum,

I made a little game for Android and iOS. On Android there is no problems, all works fine. However, in iOS, the physics work really slow. We have other things like animations that work well, without any delay. Maybe sometimes show some frame drops, but I don’t think is related. But with the physics is different.

Do you know why is this happening? Thanks!

Hi just wondering which version of cocos are you using? and are you using any external physics library? For us to do better investigation, do you mind to make us a small repo scene?

we are using 3.4.2 we are not using external physics.

We did a new test, if we run the game from the mobile browser, using the QR code, all works fine. The problem is when we do a build. we have more than 100 instances of a tiles and seems the game become more slow if we have more instances. The strange thing is that with the browser is working fine without problems.

Any clue? any parameter to compile the libcocos or something that can cause this behaviour?

Logs from XCode just in case.
log.txt.zip (2.4 KB)

Hi @AndyTian, @snavarro is taking care of this issue. Can you please take a look to what is he saying? Thanks ^^

I have been testing the game in ios, and what i found was the collisions are the ones that make the fps to drop drastically. We have like 70 balls in the screen sith colliders2d and rigidbody2d, if we run the game on android or webgl with ios or android, the game works perfect. Once we do a Xcode project. we can see the collisions are killing the app, each time the balls collide the fps drops from 100 to 16 or 17.

No idea why on android works fine and ios is not.
Thks in advance for your help.

Which physics backend are you using? Bullet or PhysX ? We strongly suggest you to use PhysX on iOS

The root reason of this issue is that native environment on iOS doesn’t support JIT, and we have only integrated bullet with wasm and js version, so the performance is very limited. While for PhysX, we are using native library to on iOS, so it should be much more performant

we are using box2D. we use 2D physics.

Ah, sorry, we currently don’t have native 2d physics library, you need to better control physics calculation, for example,

  1. structure the scene nodes with different physics groups and only check between necessary groups
  2. disable physics components which are far enough

Do you think that the 3d physics will perform better than box2D ?

On iOS definitely

ok, i will change all the physics to 3D and lets hope the size of libcocos will be less than 9 MB because we are doing an appclip :smiley:

Thks pandemicro

No problem, in which scenario you are distributing the appclip ? We initially thought it would be a very good thing, but after all it doesn’t seem to be very popular

We are doing a videogame, and the appclips is a small demo of this videogame. the videogame is done in Unity3d, but the unity3d libraries are too big for the appclip so we search for a light engine to do it and we chose cocos. We already deployed the “instant google play” game successfully , and now we are doing the app clip. we did our own tool to merge both projects into Xcode, just this bugs remains.
Thks for your help.

I thought appclip is tied to some localization based logic, and user might need to scan QR code to launch it. Just curious, how are you going to distribute ?

There are several ways to distribute it, in our case, the physical stores will have the QR code + the webside, and AppsFlyer has make an interesting feature that we will use.

so we will use 3 distribution channel, Ads + web + QR on stores.

Thks.

Thanks for sharing!