battery saving
DESCRIPTION
Principles from WWDC 2014 Session 710 and 712 in iOS development. To save your battery life is major concern since user could check the battery usage in iOS8. Those battery master will be deleted forever, and you are no longer be able to blame the reason of draining on other apps (Map/Facebook).TRANSCRIPT
![Page 1: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/1.jpg)
Writing Energy Efficient Code
2014 Session 710 & 712
![Page 2: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/2.jpg)
What Uses Energy?
![Page 3: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/3.jpg)
Concept
Coalesce work
Cut down wakes
![Page 4: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/4.jpg)
![Page 5: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/5.jpg)
![Page 6: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/6.jpg)
“To sleep is the prepare for the longer journey ahead”
![Page 7: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/7.jpg)
Preview
![Page 8: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/8.jpg)
Do It Never
![Page 9: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/9.jpg)
Do it never
• Avoid unneeded work
Respond to changes in active state
![Page 10: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/10.jpg)
Do it neverLocation
“Stop Location Updates”
![Page 11: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/11.jpg)
Do it at better time
• NSURLSession Background Session
• Understand requirements
• Overhead cost
Let the system schedule work
![Page 12: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/12.jpg)
Do it at better timeNSURLSession - Discretionary Tasks
![Page 13: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/13.jpg)
Do It at Better Time
![Page 14: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/14.jpg)
• Network conditions Throughput
• Reduce data sizes Quality, Compress
• Avoid redundant transfers Caching, Resumable
• Handle errors Timeout, Retry
Do it at better timeNetworking
![Page 15: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/15.jpg)
Do It More Efficiently
![Page 16: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/16.jpg)
Do it more efficiently
Quality of Service NSOperation and NSOperationQueue
Specify QoS classes on your work
![Page 17: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/17.jpg)
• Specify the responsiveness and energy requirements of work.
• Classify long-running or resource-intensive operations in your existing code.
• Aim for >90% of time at Utility or below when the user is inactive.
Do it more efficientlyQuality of Service
![Page 18: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/18.jpg)
Do It Less
![Page 19: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/19.jpg)
Do it less
• Reduce CPU Use minimize timers• Performance Unit Test (Prince)
• Limit Screen Updates• Visual effects avoid placing over updates elements
• Minimize your I/O
Optimize and improve your resource use
![Page 20: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/20.jpg)
Do it less
• Device will wake for notifications
• Set Push notification priority
Notifications
![Page 21: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/21.jpg)
Summary
“Be a considerate background app”
![Page 22: Battery Saving](https://reader033.vdocuments.net/reader033/viewer/2022042816/558fc4fc1a28ab83318b467e/html5/thumbnails/22.jpg)
Related
2013 Session 712 Energy Best Practices