Access performance values on launch


I noticed within the editor that I can turn the debug options on and see things like frame rate and time for the CPU among other things. We are trying to support as many phones as we can for our projects because at the end of the game we are planning on giving prizes away with links to other pages. As such, it wouldn’t be quite right for someone with a bad phone to open up the game and be unable to play and thus unable to access the prizes. Is there anyway within PlayCanvas to either detect the frame rate/CPU load and decide that the phone wont have a good experience or detect a crash or a freeze and default to something else? Let me know if anyone has a solution to this. We would love to (and I know this is asking a lot) be able to detect this all the way down to an iPhone 5 (or at least a 6) just to be able to serve a “sorry your device isn’t supported” with a link rather than the PlayCanvas app.

Hey @Jake_Johnson, try the mini_stats feature when launching, this shows some important data like Draw Calls, and CPU/GPU usage in real time. We’ve been using the same to test our own mobile game for compatibility, and it works really well. Check out the official docs here.

Hope this helps!

1 Like

Hi @Jake_Johnson,

Some of the profiler stats are available under the namespace as well. I am not sure if all of them are listed when running a production build of the engine, but give it a try:


IIRC, the CPU and GPU time are still valid in the production version for the engine.

You may want to check the delta time between frames on the title screen or during some sort of early benchmark to see if the device is capable.

I do wonder if you can rely on the browser user agent to check the iOS version as iPhone 5 only goes up to a certain version?

The problem with a crash due to device capabilities is that it will crash the webview so you wouldn’t be able to transition out AFAIK.


Wait so there is a way to read the device version through javascript? Because if that is the case then you could just have a switch where if the game isn’t in the list of supported devices then you could just handout a coupon.

Also, is the frame rate able to be read during the loading screen is that what you are saying?

It is possible to get the user agent which may or may not give the relevant information.

This is an old StackOverflow but gives you an idea: regex - Detecting iOS Version Number from User Agent using Regular Expressions - Stack Overflow

Here’s a library that could make it easier: GitHub - faisalman/ua-parser-js: UAParser.js - Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment.

Here’s another: GitHub - etienne-martin/device-detector-js: A precise user agent parser and device detector written in TypeScript

On Android, you could get the GPU information too, see bottom of this page: Device Pixel Ratio | Learn PlayCanvas

No, it would have to once the app has started to get a decent representation or during some mini benchmark when you start.


You could read the User-Agent of the device, and if you don’t want to have to parse all of that you could give platform.js a try:


Okay so that UAParser library seems pretty solid for this use case. After looking through the startup file though, would it work to just include something else on the try and catch block? I noticed it already notifies the user if there is a context creation error. Are the errors that are thrown in that block reliable? Could you just include “hey go claim your prize here” on an html button instead of sending an error? Just curious if anyone has ever done something like this before where if PlayCanvas fails there is a backup.

It’s more if the app does more than what the hardware is capable of (eg running out of memory). At that point, it’s too late, the whole page crashes and doesn’t render any DOM.

You may want to have a custom front page to handle the UA before starting the PlayCanvas app.