•writing energy efficient apps...daniel schucker, software power engineer prajakta karandikar,...
TRANSCRIPT
![Page 1: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/1.jpg)
#WWDC17
© 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer
•Writing Energy Efficient Apps • Session 238
App Frameworks
![Page 2: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/2.jpg)
![Page 3: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/3.jpg)
![Page 4: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/4.jpg)
![Page 5: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/5.jpg)
•Battery Life Concepts•Energy Efficient Coding•Energy Debugging Tools and Demo•Final Thoughts
![Page 6: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/6.jpg)
•General Battery Life Concepts
![Page 7: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/7.jpg)
What Is Energy?
Time
Pow
er
![Page 8: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/8.jpg)
What Is Energy?
Time
Pow
er
Idle
OverheadOverhead
Active
Active
![Page 9: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/9.jpg)
What Is Energy?
Time
Pow
er
Idle
Active
Active
OverheadOverhead
Energy
![Page 10: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/10.jpg)
What Is Energy?
Time
Pow
er
Idle
Active
Active
Overhead Dynamic cost
Fixed cost
Overhead
OverheadYour work
![Page 11: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/11.jpg)
Balancing Power and Battery Life
![Page 12: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/12.jpg)
Balancing Power and Battery Life
![Page 13: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/13.jpg)
What Consumes Energy?
![Page 14: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/14.jpg)
What Consumes Energy?
Processing Networking Location Graphics
![Page 15: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/15.jpg)
How to Reduce Energy Consumption
Identify
Optimize
Coalesce
Reduce
![Page 16: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/16.jpg)
•Energy Efficient Coding
![Page 17: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/17.jpg)
![Page 18: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/18.jpg)
Social Networking App
Main feed
Post a photo
Analytics
![Page 19: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/19.jpg)
Social Networking App Main Feed
Current implementation • Reloads on a timer
![Page 20: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/20.jpg)
Social Networking App Energy Impact
Feed Refresh
Time
Pow
er
![Page 21: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/21.jpg)
Social Networking App Energy Impact
Feed Refresh
Time
Pow
er
![Page 22: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/22.jpg)
Social Networking App Energy Impact
Radio costFeed Refresh
Time
Pow
er
Dynamic cost
Overhead cost
![Page 23: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/23.jpg)
Social Networking App Main Feed
Reload only when needed • User interaction • Notification
Use NSURLSession Default Session • New: WaitsForConnectivity • Cache
![Page 24: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/24.jpg)
Social Networking App Energy Impact
Radio costFeed Refresh
Time
Pow
er
Dynamic cost
Overhead cost
User Interaction Notification
![Page 25: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/25.jpg)
// Setup NSURLSession Default Session let config = URLSessionConfiguration.default()
// Use WaitsForConnectivity config.waitsForConnectivity = true
// NSURLSession Cache let cachesDirectoryURL = FileManager.default().urlsForDirectory(.cachesDirectory, inDomains: .userDomainMask).first! let cacheURL = try! cachesDirectoryURL.appendingPathComponent("MyCache") var diskPath = cacheURL.path
let cache = URLCache(memoryCapacity:16384, diskCapacity: 268435456, diskPath: diskPath) config.urlCache = cache config.requestCachePolicy = .useProtocolCachePolicy
![Page 26: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/26.jpg)
// Setup NSURLSession Default Session let config = URLSessionConfiguration.default()
// Use WaitsForConnectivity config.waitsForConnectivity = true
// NSURLSession Cache let cachesDirectoryURL = FileManager.default().urlsForDirectory(.cachesDirectory, inDomains: .userDomainMask).first! let cacheURL = try! cachesDirectoryURL.appendingPathComponent("MyCache") var diskPath = cacheURL.path
let cache = URLCache(memoryCapacity:16384, diskCapacity: 268435456, diskPath: diskPath) config.urlCache = cache config.requestCachePolicy = .useProtocolCachePolicy
![Page 27: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/27.jpg)
// Setup NSURLSession Default Session let config = URLSessionConfiguration.default()
// Use WaitsForConnectivity config.waitsForConnectivity = true
// NSURLSession Cache let cachesDirectoryURL = FileManager.default().urlsForDirectory(.cachesDirectory, inDomains: .userDomainMask).first! let cacheURL = try! cachesDirectoryURL.appendingPathComponent("MyCache") var diskPath = cacheURL.path
let cache = URLCache(memoryCapacity:16384, diskCapacity: 268435456, diskPath: diskPath) config.urlCache = cache config.requestCachePolicy = .useProtocolCachePolicy
![Page 28: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/28.jpg)
// Setup NSURLSession Default Session let config = URLSessionConfiguration.default()
// Use WaitsForConnectivity config.waitsForConnectivity = true
// NSURLSession Cache let cachesDirectoryURL = FileManager.default().urlsForDirectory(.cachesDirectory, inDomains: .userDomainMask).first! let cacheURL = try! cachesDirectoryURL.appendingPathComponent("MyCache") var diskPath = cacheURL.path
let cache = URLCache(memoryCapacity:16384, diskCapacity: 268435456, diskPath: diskPath) config.urlCache = cache config.requestCachePolicy = .useProtocolCachePolicy
![Page 29: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/29.jpg)
Social Networking App Posting a Photo
Current implementation • Send immediately • Retry on failure
![Page 30: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/30.jpg)
Social Networking App Energy Impact
Radio costSend photo cost
Time
Pow
er
Dynamic cost
Overhead cost
Send Photo Timeout
![Page 31: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/31.jpg)
Social Networking App Energy Impact
Radio costSend photo cost
Time
Pow
er
Dynamic cost
Overhead cost
Send Photo Timeout Retry Timeout
![Page 32: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/32.jpg)
Social Networking App Posting a Photo
Use NSURLSession Default Session • Minimize retries • Set timeouts • Batch Transactions
When retry limit hit • Use Background Session
![Page 33: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/33.jpg)
Social Networking App Energy Impact
Radio costSend photo cost
Time
Pow
er
Dynamic cost
Overhead cost
Send Photo
Timeout
Retry
TimeoutCreate Background
Session
![Page 34: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/34.jpg)
Social Networking App Sending analytics data
Use NSURLSession Background Session • Automatic retries • Throughput monitoring
Properties • New
- Start time - Workload size
• Discretionary
Analytics
![Page 35: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/35.jpg)
Social Networking App Sending analytics data
Use NSURLSession Background Session • Automatic retries • Throughput monitoring
Properties • New
- Start time - Workload size
• Discretionary
Analytics
![Page 36: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/36.jpg)
Social Networking Application Energy Impact
Time
Pow
er
Dynamic cost
Overhead cost
Other networking costSend analytics cost
Radio cost
![Page 37: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/37.jpg)
Social Networking Application Energy Impact
Time
Pow
er
Dynamic cost
Overhead cost
Other networking costSend analytics cost
Radio cost
![Page 38: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/38.jpg)
// Setup NSURLSession Background Session let config = URLSessionConfiguration.background(withIdentifier: "com.socialapp.background") let session = URLSession(configuration: config, delegate: …, delegateQueue: …)
// Set discretionary property config.discretionary = true
// Create Request and Task var request = URLRequest(url: URL(string: "https://www.example.com/")!) request.addValue("…", forHTTPHeaderField: “…”) let task = session.downloadTask(with: request)
// Set time window task.earliestBeginDate = Date(timeIntervalSinceNow: 2 * 60 * 60)
// Set workload size task.countOfBytesClientExpectsToSend = 80 task.countOfBytesClientExpectsToReceive = 2048
task.resume()
![Page 39: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/39.jpg)
// Setup NSURLSession Background Session let config = URLSessionConfiguration.background(withIdentifier: "com.socialapp.background") let session = URLSession(configuration: config, delegate: …, delegateQueue: …)
// Set discretionary property config.discretionary = true
// Create Request and Task var request = URLRequest(url: URL(string: "https://www.example.com/")!) request.addValue("…", forHTTPHeaderField: “…”) let task = session.downloadTask(with: request)
// Set time window task.earliestBeginDate = Date(timeIntervalSinceNow: 2 * 60 * 60)
// Set workload size task.countOfBytesClientExpectsToSend = 80 task.countOfBytesClientExpectsToReceive = 2048
task.resume()
![Page 40: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/40.jpg)
// Setup NSURLSession Background Session let config = URLSessionConfiguration.background(withIdentifier: "com.socialapp.background") let session = URLSession(configuration: config, delegate: …, delegateQueue: …)
// Set discretionary property config.discretionary = true
// Create Request and Task var request = URLRequest(url: URL(string: "https://www.example.com/")!) request.addValue("…", forHTTPHeaderField: “…”) let task = session.downloadTask(with: request)
// Set time window task.earliestBeginDate = Date(timeIntervalSinceNow: 2 * 60 * 60)
// Set workload size task.countOfBytesClientExpectsToSend = 80 task.countOfBytesClientExpectsToReceive = 2048
task.resume()
![Page 41: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/41.jpg)
Social Networking Application WatchOS
Use background session for screen off work • Complication updates • Background app refresh • Runtime when task completes
![Page 42: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/42.jpg)
Networking Best Practices
Identify • Ensure transactions not repeated
Optimize • Use background session
Coalesce • Batch transactions
Reduce • Minimize retries
![Page 43: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/43.jpg)
![Page 44: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/44.jpg)
Location Best Practices Location APIs
Continuous location
Quick location update
Region monitoring
Visit monitoring
Significant location change
![Page 45: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/45.jpg)
Location Best Practices Continuous Location
Navigate to a destination • Continuous location updates • Prevents device sleep
Stop location updates • Allows device to sleep
![Page 46: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/46.jpg)
// Create location manager locationManager = CLLocationManager() locationManager.delegate = self locationManager.requestWhenInUseAuthorization()
// Set desired accuracy, auto-pause, and activity type appropriately locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers locationManager.pausesLocationUpdatesAutomatically = true locationManager.activityType = CLActivityTypeNavigation
// Set allows background if its needed locationManager.allowsBackgroundLocationUpdates = true
// Start location updates locationManager.startUpdatingLocation()
![Page 47: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/47.jpg)
// Create location manager locationManager = CLLocationManager() locationManager.delegate = self locationManager.requestWhenInUseAuthorization()
// Set desired accuracy, auto-pause, and activity type appropriately locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers locationManager.pausesLocationUpdatesAutomatically = true locationManager.activityType = CLActivityTypeNavigation
// Set allows background if its needed locationManager.allowsBackgroundLocationUpdates = true
// Start location updates locationManager.startUpdatingLocation()
![Page 48: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/48.jpg)
// Create location manager locationManager = CLLocationManager() locationManager.delegate = self locationManager.requestWhenInUseAuthorization()
// Set desired accuracy, auto-pause, and activity type appropriately locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers locationManager.pausesLocationUpdatesAutomatically = true locationManager.activityType = CLActivityTypeNavigation
// Set allows background if its needed locationManager.allowsBackgroundLocationUpdates = true
// Start location updates locationManager.startUpdatingLocation()
![Page 49: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/49.jpg)
// Create location manager locationManager = CLLocationManager() locationManager.delegate = self locationManager.requestWhenInUseAuthorization()
// Set desired accuracy, auto-pause, and activity type appropriately locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers locationManager.pausesLocationUpdatesAutomatically = true locationManager.activityType = CLActivityTypeNavigation
// Set allows background if its needed locationManager.allowsBackgroundLocationUpdates = true
// Start location updates locationManager.startUpdatingLocation()
![Page 50: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/50.jpg)
// Create location manager locationManager = CLLocationManager() locationManager.delegate = self locationManager.requestWhenInUseAuthorization()
// Set desired accuracy, auto-pause, and activity type appropriately locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers locationManager.pausesLocationUpdatesAutomatically = true locationManager.activityType = CLActivityTypeNavigation
// Set allows background if its needed locationManager.allowsBackgroundLocationUpdates = true
// Start location updates locationManager.startUpdatingLocation()
![Page 51: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/51.jpg)
// Start location updates locationManager.startUpdatingLocation()
// Get location updates …
// Disable background updates when no longer needed locationManager.allowsBackgroundLocationUpdates = false
// Stop location when no longer needed locationManager.stopUpdatingLocation()
![Page 52: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/52.jpg)
// Start location updates locationManager.startUpdatingLocation()
// Get location updates …
// Disable background updates when no longer needed locationManager.allowsBackgroundLocationUpdates = false
// Stop location when no longer needed locationManager.stopUpdatingLocation()
![Page 53: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/53.jpg)
// Start location updates locationManager.startUpdatingLocation()
// Get location updates …
// Disable background updates when no longer needed locationManager.allowsBackgroundLocationUpdates = false
// Stop location when no longer needed locationManager.stopUpdatingLocation()
![Page 54: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/54.jpg)
Location Best Practices Request location
Get news based on current location • Use quick location update
locationManager.requestLocation()
![Page 55: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/55.jpg)
Location Best Practices Request location
Get news based on current location • Use quick location update
locationManager.requestLocation()
![Page 56: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/56.jpg)
Location Best Practices Region monitoring
Updating content when arriving at home • Use region monitoring
// Create the geographic region to be monitored. let geoRegion = CLCircularRegion(center: overlay.coordinate, radius: radius, identifier: identifier) locationManager.startMonitoring(for: geoRegion)
![Page 57: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/57.jpg)
Location Best Practices Region monitoring
Updating content when arriving at home • Use region monitoring
// Create the geographic region to be monitored. let geoRegion = CLCircularRegion(center: overlay.coordinate, radius: radius, identifier: identifier) locationManager.startMonitoring(for: geoRegion)
![Page 58: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/58.jpg)
Location Best Practices Visit monitoring
Updating content when arriving at frequently visited locations • Use visit monitoring
// Start monitoring locationManager.startMonitoringVisits()
// Stop monitoring when no longer needed locationManager.stopMonitoringVisits()
![Page 59: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/59.jpg)
Location Best Practices Visit monitoring
Updating content when arriving at frequently visited locations • Use visit monitoring
// Start monitoring locationManager.startMonitoringVisits()
// Stop monitoring when no longer needed locationManager.stopMonitoringVisits()
![Page 60: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/60.jpg)
Location Best Practices Visit monitoring
Updating content when arriving at frequently visited locations • Use visit monitoring
// Start monitoring locationManager.startMonitoringVisits()
// Stop monitoring when no longer needed locationManager.stopMonitoringVisits()
![Page 61: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/61.jpg)
Location Best Practices Significant location change
Updating content based user location • Use significant location change
// Start monitoring locationManager.startMonitoringSignificantLocationChanges()
// Stop monitoring when no longer needed locationManager.stopMonitoringSignificantLocationChanges()
![Page 62: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/62.jpg)
Location Best Practices Significant location change
Updating content based user location • Use significant location change
// Start monitoring locationManager.startMonitoringSignificantLocationChanges()
// Stop monitoring when no longer needed locationManager.stopMonitoringSignificantLocationChanges()
![Page 63: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/63.jpg)
Location Best Practices Significant location change
Updating content based user location • Use significant location change
// Start monitoring locationManager.startMonitoringSignificantLocationChanges()
// Stop monitoring when no longer needed locationManager.stopMonitoringSignificantLocationChanges()
![Page 64: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/64.jpg)
Location Best Practices
Identify: • Accuracy level needed
Optimize: • Use alternatives to continuous location
Reduce: • Stop location when not used
Coalesce: • Defer location updates
![Page 65: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/65.jpg)
![Page 66: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/66.jpg)
Graphics
Minimize screen updates • Ensure screen updates provide needed changes
Review blur usage • Avoid placing blurs over updating elements
![Page 67: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/67.jpg)
Minimize use of Discrete GPU
Use Discrete GPU only when: • Animation performance suffers • Functionality isn't supported
Graphics MacOS
![Page 68: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/68.jpg)
MTLCreateSystemDefaultDevice() • Always uses Discrete GPU
Use Integrated GPU when possible • MTLCopyAllDevices
- Select device with isLowPower attribute set
Graphics MacOS—Metal
![Page 69: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/69.jpg)
Make your app mux-aware by either: • Adding NSSupportsAutomaticGraphicsSwitching to your info.plist
• Creating an OpenGL context with the automatic graphics switching attribute
Graphics MacOS—OpenGL
let attributes3 : [CGLPixelFormatAttribute] = [ kCGLPFASupportsAutomaticGraphicsSwitching, kCGLPFAAllowOfflineRenderers, CGLPixelFormatAttribute(0) ] CGLChoosePixelFormat(attributes3, &pix, &npix) CGLCreateContext(pPixelFmt, nil, &pContext)
![Page 70: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/70.jpg)
Graphics Best Practices
Identify: • Blur usage
Optimize: • Only use discrete GPU when needed (macOS)
Reduce: • Minimize screen updates
![Page 71: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/71.jpg)
![Page 72: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/72.jpg)
Processing Best Practices
Identify tasks
Do work quickly and efficiently
Avoid timers
Set leeway
![Page 73: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/73.jpg)
Background Processing
Time
Pow
er
Idle
Background workForeground work Backgrounded
Foregrounded
Suspended
Overhead
Dynamic cost
Fixed cost
![Page 74: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/74.jpg)
Background Processing
Finish work quickly
Use background app refresh
Call completion handler
![Page 75: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/75.jpg)
Background Processing iOS
PushKit API • Now has completion handler • Call after handling push
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType, withCompletionHandler completion: @escaping () -> Void) { // Process the incoming push payload here...
// Then signal that processing has completed completion() }
![Page 76: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/76.jpg)
Background Processing iOS
PushKit API • Now has completion handler • Call after handling push
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType, withCompletionHandler completion: @escaping () -> Void) { // Process the incoming push payload here...
// Then signal that processing has completed completion() }
![Page 77: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/77.jpg)
Background Processing Current
Time
Pow
er
Idle
Background work
Incoming Push
Suspended
Overhead
Dynamic cost
Fixed cost
![Page 78: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/78.jpg)
Background Processing With Completion Handler
Time
Pow
er
Idle
Background work
Incoming Push
Overhead
Dynamic cost
Fixed cost
Completion Handler
![Page 79: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/79.jpg)
Background Processing WatchOS
New: Navigation background mode • CPU limits like Workout • Minimize networking • Ensure work is relevant to the user
Use background app refresh and complication updates to refresh data
![Page 80: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/80.jpg)
Background Processing
Identify: • Work done in the background
Optimize: • Use Background App Refresh
Reduce: • Limit transactions
Coalesce: • Use NSURLSession background session
![Page 81: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/81.jpg)
•Battery Life Concepts •Energy Efficient Coding •Energy Debugging Tools and Demo •Final Thoughts
![Page 82: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/82.jpg)
Overview
Energy debugging tools
Measuring energy impact of your apps
Demo
![Page 83: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/83.jpg)
Settings: Battery
![Page 84: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/84.jpg)
Settings: Battery
Can be deleted by users
![Page 85: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/85.jpg)
Energy Debugging Workflow
Energy Gauges
![Page 86: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/86.jpg)
![Page 87: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/87.jpg)
![Page 88: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/88.jpg)
![Page 89: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/89.jpg)
![Page 90: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/90.jpg)
![Page 91: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/91.jpg)
![Page 92: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/92.jpg)
![Page 93: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/93.jpg)
![Page 94: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/94.jpg)
![Page 95: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/95.jpg)
![Page 96: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/96.jpg)
![Page 97: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/97.jpg)
![Page 98: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/98.jpg)
![Page 99: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/99.jpg)
![Page 100: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/100.jpg)
![Page 101: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/101.jpg)
![Page 102: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/102.jpg)
![Page 103: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/103.jpg)
![Page 104: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/104.jpg)
![Page 105: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/105.jpg)
![Page 106: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/106.jpg)
![Page 107: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/107.jpg)
![Page 108: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/108.jpg)
![Page 109: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/109.jpg)
![Page 110: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/110.jpg)
![Page 111: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/111.jpg)
![Page 112: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/112.jpg)
![Page 113: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/113.jpg)
![Page 114: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/114.jpg)
![Page 115: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/115.jpg)
![Page 116: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/116.jpg)
![Page 117: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/117.jpg)
![Page 118: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/118.jpg)
Scenarios for Energy Debugging
General/common • Launch and Idle • Background
Application specific • For example, Navigation App
- Search for an address - Get directions - Navigate
![Page 119: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/119.jpg)
•Demo
![Page 120: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/120.jpg)
•Battery Life Concepts •Energy Efficient Coding •Energy Debugging Tools and Demo •Final Thoughts
![Page 121: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/121.jpg)
Final Thoughts
Use NSURLSession Background Session
Minimize use of continuous location
Avoid timers
Coalesce work
Use energy gauges
![Page 122: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/122.jpg)
Related Sessions
Advances in Networking, Part 1 Executive Ballroom Wednesday 3:00PM
Advances in Networking, Part 2 Executive Ballroom Wednesday 4:00PM
NSURLSession: New Features and Best Practices WWDC 2016
Networking for the Modern Internet WWDC 2016
![Page 123: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/123.jpg)
Labs
Power and Performance Lab Technology Lab I Fri 11:00AM–1:00PM
![Page 124: •Writing Energy Efficient Apps...Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer •Writing Energy Efficient Apps](https://reader036.vdocuments.net/reader036/viewer/2022062918/5edeaa96ad6a402d6669ff9e/html5/thumbnails/124.jpg)