Mobile Optimization

Following on from some other threads and answers topics. I thought a general discussion on how to create optimal mobile applications using PlayCanvas would be useful.

First things first, check out the page on the user manual about general optimization:

1 Like

I found a memory leak bug on my app.
It will cause of app stress.

And it is not affect soon at PC environment.(The OS swap memory by using storage)
If your app become slower and slower, you should seek memory leak bug.

Ok I’m on the cusp of publishing a new general purpose Collision Detection and interpenetration preventer for PlayCanvas. In extreme tests it’s over 300x faster than a setup using Ammo (2500 active colliders - CD 0.07ms Ammo 22.7ms). Should be useful for most games that don’t focus on physics but instead need to know when things hit and to smoothly stop objects interpenetrating. Currently works with spheres, boxes, capsules and meshes (though I meshes aren’t anywhere near as performant in the first release).

Also - mesh combining seems to work well for me. I’ve got scripts for fixed meshes and for mobile, unanimated characters, will work on animated combining next. Seems to double the speed in my tests.

1 Like

That would be pretty cool, physics was going to be the first point of order in this thread. I have been thinking about ways to get some simple intersection / collision / triggers working, but it’s a difficult problem.

So first mobile optimization tip:

Do not use 3D Rigid Body Physics

PlayCanvas includes the 3D physics engine ammo.js integrated into the Editor. Ammo.js is a version of the Bullet C++ physics engine compiled using Emscripten to Javascript. As such it is a relatively large block javascript and a bit of a black box debugging-wise. We have found that Emscripten compiled code will often perform badly on mobile. In addition, 3D physics is a CPU intensive operation and will stress mobile CPUs.

By default a PlayCanvas project will not include ammo in the project. In your project settings there is an option to Enable Physics. If this is enabled, ammo will be included in your project. We will automatically enable this option if you add a collision or rigidbody component to an Entity while in the Editor. For mobile projects, ensure that you have disable physics in your project settings and removed all rigidbody and collision components from Entities in your scenes.


Usually we suggest that you implement as simple a physics/collision system as required for your game. Most mobile games do not need to be simulating rigidbodies and if you can get away with doing simple point-in-sphere or AABB (Axis-Aligned Bounding Box) intersection tests, then you should do that. As noted above, you will achieve must faster results for these specific cases than for a generalized solution like ammo.

1 Like

Version 0.1 of Collision Detection is now available for anyone who’d like a go.

Full documentation and demos are here:


PlayCanvas is an excellent WebGL game development engine
that is well suited to many tasks. One of the major limitations
however is its reliance on Ammo.js - an Emscriptem compilation
of the Bullet physics library.

Bullet is a fantastic library, a brilliant piece of work,
but when used in PlayCanvas - especially on mobile
it causes slow frame rates and significant garbage
collection cycles.

New users especially fall foul of relying on the inbuilt
physics only to find their game will never perform
the way they want.

There are times when you need a physics engine, but
much of the time you can simply get away with collision
detection. More advanced games require raycasts and full
protection from object penetration too.

Collision Detection is a library designed to fulfil the
need for robust, fast collision detection and object
separation that is suitable for mobile games built
with PlayCanvas. It fully support raycasting and
compound colliders.


Collision Detection supports the following features:

  • Very high performance broad and narrow phase collision
  • Raycasts with multiple hits
  • PlayCanvas collision components of the types: Box,
    Sphere, Capsule and Mesh
  • Script function call backs on the colliding object
    and any parent that defines a suitable callback
  • Collision events
  • A “Simple” rigid body that prevents object penetration
    and allows simple pushing of objects in the world