AIR for iOS: Power Saving

What coding tricks, flag compilations, software architecture considerations can be applied to reduce power consumption in an AIR for iOS application (or reduce power consumption in an existing application that burns too much battery)?

+3


source to share


3 answers


One of the biggest things you can do is adjust the frame rate based on the state of the app.

You can do this by adding handlers inside your App.mxml

<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        activate="activate()" deactivate="close()" />

      



Inside activation and close methods

//activate
FlexGlobals.topLevelApplication.frameRate = 24;

//deactivate
FlexGlobals.topLevelApplication.frameRate = 2;

      

You can also play with this number depending on what your application is doing. If you are just displaying text, try omitting fps. This should give you the greatest energy savings benefit.

+2


source


Typically, high power consumption can result from:

  • heavy network use
  • no standby mode to display while application is idle
  • Does not apply to using location services
  • constant cpu use

Regarding (flex / flash) AIR, I would suggest that:

First you use Flex Profile Manager + Task Manager and keep track of CPU and memory usage. Try to reduce them as much as possible. Once you have this low on windows / mac, they will go down (theoretically on mobile).

The next step is to use network monitor and reduce the number and size of network (webservice) calls. Try to identify unnecessary network activity and eliminate it.



Try to detect any idle state of the app (maybe in flex, not sure about flash) and maybe put the whole app to sleep (if you have a fireworks animation running, just hit stop ())

Also I'm not sure about this, but I'm sure to cut down on the processor and use more gpu: using Stage3D (now available with Air 3.2 also for mobile) when you are doing complex actions. This can shorten the execution time, as there is HW acceleration, so the power consumption can be lower.

If I am wrong about something, please comment / downgrade (as you like), but this is my personal impression.

Update 1

As pointed out in the comments, there is no 100% relationship between desktop and mobile CPU usage, but "in theory" at a low level, we should have at least the same CPU usage trend.

+1


source


My advice:

  • Profile your application in the first step with the profiler from Flash Builder
  • If you have a Mac, profile the app using tools from Xcode

And it is important:

Simulator, IPA-Interpreter packages, and IPA-Test build behave differently.

Simulator - proforma optimization

IPA-Interpreter - Get an idea of โ€‹โ€‹performance

IPA-Test - "Real" Performance Behavior

And finally, the AppStore-Build test, this is the fastest (in terms of performance) package mode. Additionally, we have seen that all of these modes can change.

0


source







All Articles