Slide 1

Slide 1 text

Save the environment with Xcode One line can change a code... Manuel @stuffmc Carrasco Molina Code 4 Future @stuffmc • Save the environment with Xcode, June '19, AltConf Paris

Slide 2

Slide 2 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 2

Slide 3

Slide 3 text

> whoami && whyami? ✔ ! guy born in " living in since 16 years → ✔ 22 years of software dev, 11 with techs → ✔ 8 years of political involvement with the party ✔ 5 years of climate ) & refugees activism ✔ 6 + years , without - meat, half of it vegan @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 3

Slide 4

Slide 4 text

Ethics FTW This talk is about your Karma... @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 4

Slide 5

Slide 5 text

5

Slide 6

Slide 6 text

One line can change the code ✔ If can change the code, it can change the App ✔ If can change the App, it can change the Phone ✔ With over 2.2 billion Phones... ✔ It can change the World! @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 6

Slide 7

Slide 7 text

Your Code can change the world ✔ Don't let energy optimization be the next testing ✔ There's never enough time or money for testing ✔ Same with Security... ✔ Some Security Company have no time for design @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 7

Slide 8

Slide 8 text

Settings > Battery ✔ Where the user will go if the battery is draining. ✔ You don't want your app in this list. ✔ It's like the losers list. @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 8

Slide 9

Slide 9 text

9

Slide 10

Slide 10 text

10

Slide 11

Slide 11 text

What is Energy? @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 11

Slide 12

Slide 12 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 12

Slide 13

Slide 13 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 13

Slide 14

Slide 14 text

The 4 !fantastics numbe @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 14

Slide 15

Slide 15 text

Four by Four ✔ Identify the problem that is causing the drain ✔ Optimize the code for less battery usage ✔ Reduce the amount of things your code do ✔ Coalesce tasks that can be grouped together @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 15

Slide 16

Slide 16 text

[Background] Processing ✔ Avoid NSTimer (User refresh, notification, ...) ✔ Call Completion Handler! @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 16

Slide 17

Slide 17 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 17

Slide 18

Slide 18 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 18

Slide 19

Slide 19 text

Networking ✔ Use NSURLSessionTask's earliestBeginDate ✔ Balance between huge calls and many tiny calls ✔ More network requests = more energy ✔ Session Config: waitsForConnectivity @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 19

Slide 20

Slide 20 text

Sending analytics ✔ The best way to do it? Don't send analytics. ✔ Your company forces to do so? Can't quit? ✔ Send them in batches ✔ Session Config: discretionary @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 20

Slide 21

Slide 21 text

Location ✔ start/stopLocation? requestLocation! ✔ Region Monitoring instead of checking location! ✔ Lower location accuracy (to 3 KM if you can) ✔ Don't forget to stop (when you get enough)! @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 21

Slide 22

Slide 22 text

Graphics ✔ Minimize screen updates ✔ Review blur usage ✔ Do you really need that animation? ✔ OpenGL? Make your app mux-aware @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 22

Slide 23

Slide 23 text

Video Player ✔ Optimized from Apple ✔ Don't show persistent UI Controls too long ✔ Tagesschau layers controls on top @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 23

Slide 24

Slide 24 text

Da Tools 24

Slide 25

Slide 25 text

Energy Gauges Not working on Simulator @stuffmc • Save the environment with Xcode, June '19, AltConf Paris 25

Slide 26

Slide 26 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 26

Slide 27

Slide 27 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 27

Slide 28

Slide 28 text

Fore/Background/ Suspended @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 28

Slide 29

Slide 29 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 29

Slide 30

Slide 30 text

Instruments ✔ Untethered Profiling! ✔ Maybe environmental problems ✔ Many Profiling Templates ✔ Many Talks @ Conferences @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 30

Slide 31

Slide 31 text

Energy Logs & Organizer ✔ Similar to crash logs ✔ Agregated Logs from your users ✔ 2 weeks of History ✔ Data from TestFlight and App Store @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 31

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

References ✔ WWDC 17: Writing Energy Efficient Apps ✔ WWDC 18: What’s New in Energy Debugging ✔ Energy Efficiency Guide for iOS Apps @stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 33

Slide 34

Slide 34 text

@stuffmc • Save the environment with Xcode, June '19, AltConf Paris ! 34

Slide 35

Slide 35 text

ش ك ر ا َ ! Questions? Hire? @StuFFmc 35