Unity 5 - Profiler shows physics spikes on Android device.

Hi there,

I’m developing a game on mobile device.
I notice my game started to slow/pause every so often and decided to look it up in the profiler.

I’ve the profiler hooked onto Android Sony Z2 (Quad Core Arm CPU).

With no object moving in the scene (except for some particles), I noticed the physics spikes a fair bit on the device but not on my PC (mac).

In the project, I have only 1 rigidbody and have already remove majority of the collision model. In the physics settings, I have unchecked all the collision pair under Layer Collision Matrix.

I noticed at the bottom of the worker thread, there are some expensive functions (AABB test, rigidBodyNarrowPhase). Could the few remaining collision models and 1 rigidbody caused all that (even when there are 0 active rigidBodies and 0 contacts reported in the Physics graph)?

kimc

1 Like

Unless you’re setting the position of the object every frame (or fixed update), I don’t see any reason why you’d see a spike at all. Are you performing any other actions with the rigidbody components at all?

For that run I turned off alot of collider and removed all but 1 rigidity. At one point i was setting the same position every frame. I have turned that off since than but still didn’t help.

I’m hoping it is something silly I’m doing (At least I will be something I can fix by myself).

Once I get home, I’ll try to run a comparison of the same code on the mac (in editor) vs android device.

Drop me an email of your code that pertains to the rigidbody, I’ll check it out. I haven’t moved to U5 yet (I’m project locked to 4.6.3 by about 5 projects), but meh, it won’t be too different :slight_smile:

hi. i have some problem and i try turn off all object but physics.processing still here. Why did you do for it?

Jamie,

See attached image. Same code base, one ran in Editor, the other ran on Android.
In this setup, I have not strip out anything. 1 complex mesh collider. 21 rigidbodies + collider and 8 trigger collider.
The only thing that moves are the ones with 21 rigidbodies. The rest are stationary colliders.

I believe the physics spike has always been there throughout the ran. But it just stands out when there are no active rigidbody and zero contacts.

Anyway, I’m not sure if I’ll spend more time looking into the Android performance. Need to get myself an iOS device to see what happens there. But first… i need to get an iOS dev license. There goes $99AUD. :frowning:

1 Like

We are having the same issue. Android (LG Nexus 4), Unity 5.1.0b6.

Even with a single rigid body (CircleCollider2D) we are seeing spikes of 40-60ms in Physics.Processing.

From the Profiler timeline, it looks like the physics tasks are being run in series on the worker threads. And they’re taking much longer than expected. The profiler hierarchy doesn’t reflect the timing values (perhaps because they are run on worker threads), but you can see it in the timeline.

Has anyone made any progress on this?

I confirm the issue on Android, it kills our framerate. On some older devices our game should run close to 60fps, but currently runs at 15fps because of physics. Note we have 0 Unity physics in our game, our engineer re-wrote its own. This didn’t happen on pre Unity 5 versions.

‘Physics.Processing’ is 3D physics; nothing you do on 2D physics will affect it. 2D physics processing will be shown as ‘Physics2D.FixedUpdate’.

I have same problem too on android device

Same exact issue here, tested on Nexus 4, Oneplus One and Nexus 7 2nd gen, there are a lot of really high spikes (20-80ms) figuring under Physics.Processing method.
Test case:

  • 1 dynamic rigidbody with 1 sphere collider (non-trigger)
  • 1 plane with static collider (non moving and non trigger)
  • physics matrix with only 1 checkbox for collision between two custom layers (Plane and Ball)
  • FixedUpdate method completely empty on both objects as no scripts were attached to the objects.

Even disabling the colliders and all the checkboxes in the physics matrix and no gravity on the ball’s rigidbody, Physics.Processing is still taking up 5ms average (with peaks near 8-10ms). Seriously?

I tried this test case on an empty scene in my project, no way a single ball bouncing on a plane gets me physics spikes even as high as 20ms on a single frame on a OnePlus One…I believe there’s a bug here.

This issue seems to be overlooked, as it stands now it completely kills performance on Android.

sorry for this taking so long. The bug has been assigned to the Android team now.

Super great to hear, thanks !!

Any update on this? My android framerates are pretty boned by Physics.Processing spikes with no 3d physics in the game. Running 5.1.2 / OnePlus One.

Morten, Same exact issue here but Windows 7 64 radeon 7970 last drivers. In a empty project
No Camera or light in a fresh new Unity 5.2.b05f installation
“physics.processing” take 98.9% of resources in that peak and fps drop to 20
I do not think is a Android problem since i’m in windows.

2234353--148905--windows.jpg

1 Like

Hello there, How is it going with this ?
Thanks !
ben

Hi,

The android team have been working on it and the problem seems related to interactions between our job system, how PhysX creates jobs and how Samsungs big.LITTLE cpu balancing tech works.

The solution we’re are close to is … bailing out when there is no physics in the scene :wink:

AlanMattano, Looking at that pic I think some info is missing from the profilers, because there is no PhysX tasks actually taking up the time. I’ll add it in.

AlanMattano, or maybe not. It just processes jobs. Can you show a screenshot of the timeline profiler? There might be some other work in the job system.

Timeline in empty scene screen shot. Default settings Unity 5.2.b05f DX11.
If i move an object via script or via physics, same result, loosing visual fluidity in all that peaks (19 fps). Changing time steps do not affect the issue. Thanks for the interest.

2241079--149529--FluidityInEmptyScene.jpg