[r200] asm.js Physics CPU use on iOS

Bugs will be moved here once resolved.

Post » Wed Apr 15, 2015 2:35 pm

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:
Image

Screenshot of high CPU use:
Image

Screenshot of low CPU use:
Image

Observed Result
CPU use is high with 2 squares rotated 90 degrees. CPU is OK with just one square not rotated! :roll:
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
B
23
S
7
G
1
Posts: 186
Reputation: 2,691

Post » Wed Apr 15, 2015 2:51 pm

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.
B
22
S
9
G
7
Posts: 421
Reputation: 6,543

Post » Wed Apr 15, 2015 3:38 pm

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....
B
23
S
7
G
1
Posts: 186
Reputation: 2,691

Post » Wed Apr 15, 2015 3:47 pm

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.
B
22
S
9
G
7
Posts: 421
Reputation: 6,543

Post » Wed Apr 15, 2015 3:57 pm

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.
B
23
S
7
G
1
Posts: 186
Reputation: 2,691

Post » Tue Apr 21, 2015 12:58 pm

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.
Scirra Founder
B
378
S
219
G
84
Posts: 23,863
Reputation: 187,909

Post » Tue Apr 21, 2015 1:47 pm

@Ashely, thanks for update and explanation. There are at least a few good options I can look at.
B
23
S
7
G
1
Posts: 186
Reputation: 2,691


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest