2 Replies Latest reply: May 21, 2012 3:35 AM by kshi.gupta RSS

    performance issue on iPad

    Bonbon4345

      Hello everyone.

       

      Im developing application for an iPad in Flash Builder 4.6 SDK 4.6.0 AIR 3.1 and i have a serious problem with making smooth animations, even with some simple objects that are not sprites. All i get is 5-10 fps while elements are moving. Normal it sticks to 60 fps.

       

      I was trying to set renderMode to GPU with no luck.

       

      My sample Main.xml looks like this (based on http://coenraets.org/blog/2011/04/scrollable-and-touch-friendly-flex-charts/ ):

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                       xmlns:s="library://ns.adobe.com/flex/spark"
                                       xmlns:mx="library://ns.adobe.com/flex/mx"
                                       creationComplete="completeHandler()" cacheAsBitmap="true" cacheAsBitmapMatrix = "{new Matrix()}" frameRate="35">
        
        <fx:Script>
                          <![CDATA[
                                    protected var lastX:Number = 0;
        
                                    [Bindable] protected var viewportMax:Number = 10;
        
                                    [Bindable]
                                    private var frames:int,curTimer:int,prevTimer:int;
        
                                    [Bindable]
                                    private var framerate:String;
        
                                    protected function completeHandler():void
                                    {
                                              setInterval(updateFrameRate,1);
        
        // Simulate values
                                              var results:Array = [];
                                              for (var i:int=0; i<50; i++)
                                              {
                                                        results[i] = Math.random() * 100;
                                              }
                                              chart.dataProvider = results;
                                    }
        
                                    protected function mouseDownHandler(event:MouseEvent):void
                                    {
                                              lastX = event.stageX;
                                              systemManager.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                                              systemManager.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
                                    }
        
                                    protected function mouseMoveHandler(event:MouseEvent):void
                                    {
                                              var delta:Number = (lastX - event.stageX) / chart.width * viewportMax;
                                              if (hAxis.minimum + delta < 0)
                                              {
                                                        hAxis.minimum = 0;
                                                        hAxis.maximum = viewportMax;
                                              }
                                              else if (hAxis.maximum + delta  > chart.dataProvider.length - 1)
                                              {
                                                        hAxis.maximum = chart.dataProvider.length - 1;
                                                        hAxis.minimum = hAxis.maximum - viewportMax;
                                              }
                                              else
                                              {
                                                        hAxis.minimum += delta;
                                                        hAxis.maximum += delta;
                                              }
                                              lastX = event.stageX;
                                    }
        
                                    protected function mouseUpHandler(event:MouseEvent):void
                                    {
                                              systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                                              systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseUpHandler);
                                    }
        
                                    private final function updateFrameRate():void
                                    {
                                              frames+=1;
        
                                              curTimer=getTimer();
        
                                              if(curTimer-prevTimer>=1000){
        
                                                        framerate = String(Math.round(frames*1000/(curTimer-prevTimer)));
        
                                                        prevTimer=curTimer;
        
                                                        frames=0;
        
                                              }
        
                                              memBox.text="MEM in MB: "+ String(Math.round(1000*System.totalMemory/1048576)/1000);
        
                                    }
        
                          ]]>
        </fx:Script>
        
                <mx:ColumnChart id="chart" top="100" left="10" width="400" height="250"
                                                        mouseDown="mouseDownHandler(event)" cacheAsBitmap="true" cacheAsBitmapMatrix = "{new Matrix()}">
        <mx:series>
        <mx:ColumnSeries />
        </mx:series>
        
        <mx:horizontalAxis>
                                    <mx:LinearAxis id="hAxis" minimum="0" maximum="{viewportMax}"/>
        </mx:horizontalAxis>
        
        </mx:ColumnChart>
        <s:VGroup>
                          <s:Label text="FPS: {framerate}" />
                          <s:Label text="" id="memBox" />
                          <s:Label text="test" id="storedLang" />
        </s:VGroup>
      </s:Application>
      
      

       

       

      i'll be thankful for any help

       

      TIA

        • 1. Re: performance issue on iPad
          chris.campbell Employee Hosts

          Thanks for the post and I'm sorry you're running into this issue.  I've forwarded this along to the iOS team for their review.  In addition, if you feel like this might be a bug against AIR and iOS, please feel free to create a new bug report over at bugbase.adobe.com.  Once done, please post back with the bug's URL so that others can visit the bug to comment and vote.

           

          Thanks,

          Chris

          • 2. Re: performance issue on iPad
            kshi.gupta Adobe Employee

            Hi Bonbon,

             

            There are following suggestions that I can make. I tried your source and was able to improve the performance. During scrolls the fps number in your textfield now reads around 20 (iphone4) up from around 10.

             

            1) Use a flex mobile application instead of a flex application from your flash builder. You need not change the code at all for this mxml.

            2) Flex applications have a lot of actionscript code. Most of the time is spent in the framework code. AOT compiling your application with reduce this framework time a great deal and improve the performance a lot. Just use standard packaging from Flash Builder or use ipa-app-store target if you are packaging from command line.

            3) Remove the cache as bitmap statements from your application. I do not think they are adding any value instead I am concerned that they may be slowing it down.

            4) As always use release swf. Debug swfs have a lot of extra code.Visit this http://blogs.adobe.com/airodynamics/2011/10/21/using-release-swf-for-publishing-air-applic ations/ to know how to create a release swf.

             

            Let me know if you still face issues.