[r200] asm.js Physics CPU use on iOS

0 favourites
  • 7 posts
From the Asset Store
Shark.io
$49 USD
Shark.io in the sea full of killer sharks, Sunday of life is the game. Who knows what is happening under the sea?
  • Problem Description

    CPU use is very high on iOS using asm.js engine even though project has no active events.

    Attach a Capx

    http://www.zoytek.co.uk/bugs/physics/Physics-CPU-High.capx

    Description of Capx

    The capx displays 2 immovable squares with the physics property. Both squares are rotated 90 degrees. The CPU use in the IPA is a high 90%

    When the left square is NOT rotated, the CPU use is a modest 8%

    Browser preview performance is fine, the high CPU use only appears when both squares are rotated 90 degees. Very odd behaviour!

    Steps to Reproduce Bug

    • Export the capx to Cordova, iOS8, unminified
    • Build adhoc in the Intel XDK, download and install the IPA.
    • Install and run to observe high CPU use. (My test device is iPod 5th Gen, iOS 8.2)
    • Modify the capx to set the rotation of the left square to 0.
    • Re-export, complie, and install and observe low CPU usage (hopefully you will also see what I am seeing)

    Export settings:

    Screenshot of high CPU use:

    Screenshot of low CPU use:

    Observed Result

    CPU use is high with 2 squares rotated 90 degrees. CPU is OK with just one square not rotated!

    I've been benchmarking physics performance and I've narrowed it down to this rotation. The strange thing is I've re-done the capx from scratch and the performance has been fine. So I am confused as to why this is the case. I hope the attached capx has captures the problem.

    Box2D web is fine in both cases. Hopefully this is reproducible so you can see the unusual high CPU use with asm.js in this particular scenario.

    Expected Result

    The same CPU use for both scenarios. Both should be low single digits as nothing is happening in the event sheet, apart from the text box update every 0.05s

    Affected Browsers

      iOS problem - Cordova iOS8 App, buil with Intel XDK.

    Operating System and Service Pack

    Win 8.1 64 bit

    Construct 2 Version ID

    r200

  • It's not a bug, asm.js needs JIT to work right, AFAIK cordova is not supporting JIT right now, the support of Nitro JIT is coming with cordova-ios 4.x branch that supports WKWebView, apache guys said in April-May 2015.

  • OK. Thanks for the info.

    So, this must be why physics performance in Cordova apps is 90% lower to what I am seeing in the Safari browser?

    I made a physics demo that runs at 60FPS in Safari with 100 balls, but it's barely 10FPS when built with the Intel XDK. (iPad2/iOS8.3)

    http://www.zoytek.co.uk/test/ptest/

    Roll on JIT....

  • Safari supports JIT and every other good stuff that WKWebView is going to bring, but cordova is still working on old UIWebView, so nothing strange here.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Noted with thanks..

    One other Mobile Safari issue -do you notice occasional 0.5 second freezing with this demo in Safari?

    http://www.zoytek.co.uk/test/ptest/

    I'm testing on an iPod 5th gen and iPad 2 and it freezes momentarily, regardless of the number of objects. PC browsers are smooth.

  • Yeah, Cordova still uses UIWebView instead of the JIT-enabled WKWebView. This likely explains the performance discrepancy, since asm.js relies heavily on the ability of the JIT to optimise the code, otherwise it can be considerably slower.

    I think Ludei's Webview+ for iOS uses WKWebView, so you could try publishing with that. Alternatively I think there are a couple of third party Cordova plugins around that enable WKWebView in Cordova so you could try them out. In the long run, Cordova should end up using WKWebView by default (although this may need Apple to fix bugs in iOS), so hopefully this will resolve itself then. Another workaround is to keep using Box2dweb physics on Cordova for iOS, which isn't hit so hard if there is no JIT support.

  • Ashely, thanks for update and explanation. There are at least a few good options I can look at.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)