6 Replies Latest reply on Dec 3, 2012 5:27 AM by NicolasTony

    iOS - Performance issues when touching screen





      I am having perfomance issues when the use keep moving one finger on the screen.

      I am testing with :

      - flash builder 4.7 beta 2

      - air 3.5 (beta too I guess)

      - iPhone 3GS running on iOS 6.0.1 (also tested on an iPad3, and even though it's less horrible, the impact is still huge compared to what you could expect).

      - gpu mode

      - always published as an addhoc release build (best)



      Test 1-A) :

      - Have a completely empty project, add a fps counter (with mouseEnabled and children false).

      - run a while each frame so you force the fps under 60 (if not you won't see it going down from let's say theoric 100 to theoric 70 since fps max is 60).

      like this for example :

                                              protected function framingMouseTest(e : Event) : void {

                             var t : int = getTimer();

                             while (getTimer()-t<30) {}//this will keep flash busy


      Notice that when you keep your finger on the screen and move it you loose approximately 7ms per frame. (for example from 26 to 22fps or from 48 to 36 fps, depending on the time waited in your while).



      Test 1-B) do the same with even stage mouseEnabled false (and you could even set it + mouseChildren off recursively from stage) : same result (-7ms). Why ? Since it is all off it shouldn't take more than 1 ms no ?

      Test 1-C) add Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT; Same result (found some threads saying it would help but not that much...)

      Test 1-D) Multitouch.mapTouchToMouse = false;          It is a bit better but still around 5ms (didnt write down this one)

      Test 1-D) Multitouch.mapTouchToMouse = false; Multitouch.inputMode = MultitouchInputMode.NONE;          It is a bit better but still around 4ms (didnt write down this one) And you have now nothing left to remove I think.



      Now the horrible part :

      Test 2-A)

      Add some clips and subclips to your scene, containing bitmaps, results may vary depending on how much (let's say 30, I don't have the exact count on subcontainers), etc. but what's important is the difference between no finger and 1 finger moving on screen.

      On normal conditions (keep some mouseEnabled for the clips you need interaction add those a listener, lets say 10 total, default values for the rest) you can get about 40ms per frame down ! (for example from 36 to 14 fps) just by touching the screen.

      Test 2-B) Recursively set everything to mouseEnabled and children false after everything is added, you still get about 30ms down because of the finger, whereas it shouldn't test above the main container which already has mouseChildren false.

      Test 2-C) Multitouch.mapTouchToMouse = false; Multitouch.inputMode = MultitouchInputMode.NONE; you still get about 20ms down !!! whereas you're in a mode when touch and mouseEvents shouldn't even exist.



      I am really confused. My conclusions are :

      Performance are really impacted whatever you do when a user touch the screen + it will get worse the more clips/depth you have. Even if everything is made to disable this.


      I think anyone could test this with pretty much any app done with AIR on iOS, as long as the framerate is already <max (<60 for example), touch and move your finger and tell me what happens regarding framerate.



      What I would love :

      1) tell me what I am missing if you think this is due to some mistake on my part, if not :

      2) better perfomance when containers have mouseChildren false. It seems obvious it still takes longer to process.

      3) a mode where the touch/mouse is REALLY disabled including stage etc. It is quite obvious air does takes longer to handle touch as the scene gets more complex, even if you disable it all (seems to work only 20%...)

      4) a mode where the touch/mouse is REALLY disabled, on anything but the stage. Because you might want to handle everythin just from stage coordinates, if your project allows you to, like mine. Unfortunately right now it wouldn't give you enough performance boost (well, a bit but still maybe +20ms).



      PS : you don't even need to add mouselistener or touchlisteners (tested both), but if you do, it is worse.



      Compared to this, I am finding rendering performance pretty decent - even though it's tough for a game on a 3GS- as long as you do it properly.