Slide 1

Slide 1 text

How Open Source Powers Facebook on Android SIMON STEWART (@shs96c) Software Engineer, London

Slide 2

Slide 2 text

Facebook and OSS Over 200 repositories on GitHub 13k commits in the first 6 months of 2014 9.9M lines of code React, Shimmer, Pop, KVOController, HHVM, Hack, Presto, Warp, Haxl, and so many more…. ! Personal Story: Almost every line of code I’ve written at Facebook has been Open Sourced.

Slide 3

Slide 3 text

I’m here to talk about Android

Slide 4

Slide 4 text

The Things You May Already Know Facebook on Android is a native application Facebook on Android is worked on by 100s of engineers Facebook on Android is released every 4 weeks Facebook on mobile is used by 1 Billion Monthly Active Users

Slide 5

Slide 5 text

Building Facebook

Slide 6

Slide 6 text

AR AR AR AL AL AL AB GR AB GR AL AL AL Buck

Slide 7

Slide 7 text

Buck Smarts 1 Build rule knows all of the inputs that can affect its output 2 Changes to dx and proguard for faster compilation 3 Java ABI smarts 4 Android resource smarts 5 Daemon to watch file changes and kick off builds

Slide 8

Slide 8 text

Exopackage Exopackage is an optimization for building and installing development builds of Android apps.

Slide 9

Slide 9 text

Exopackage http://facebook.github.io/buck/article/exopackage.html Gradle Buck Speed Up Clean build 33 6 5.5 x Incremental build 17 1.7 10 x No-op build 6 0.2 30 x

Slide 10

Slide 10 text

Caching in Buck 3% 97% repeated build work unique build work

Slide 11

Slide 11 text

Android’s Evolution Gingerbread Larger displays, WebM support, better native code development Honeycomb New “Look and Feel”, Action and System bars introduced, hardware acceleration, multicore support, tweaks to SD Card access Ice Cream Sandwich UI refresh, more hardware acceleration JellyBean “Project Butter”, lock screen improvements, RTL languages now supported KitKat UI refresh, Chromium WebViews, API for messaging and storage “L” ART enabled by default, “Material Design”

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Origami

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Rebound public SpringExample() {
 ...
 springSystem = new SpringSystem();
 spring = springSystem
 .createSpring()
 .setSpringConfigConfig(DEFAULT_TRANSITION_SPRING)
 .addListener(transitionSpringListener);
 }
 public void toggleSpring() {
 double value = spring.getEndValue();
 spring.setEndValue(value == 0 ? 1 : 0);
 }

Slide 16

Slide 16 text

Rebound private class TransitionSpringListener extends SimpleSpringListener { 
 @Override
 public void onSpringUpdate(Spring spring) {
 // map the spring function to desired view properties
 float value = (float) spring.getValue();
 float scale = SpringUtil.mapValueFromRangeToRange(value, 0, 1, 0.75, 1);
 
 // update the views
 photoView.setScaleX(scale);
 photoView.setScaleY(scale);
 } 
 }

Slide 17

Slide 17 text

https://facebook.github.io/conceal/ https://flic.kr/p/29KvKK Conceal: Fast Cryptography

Slide 18

Slide 18 text

Source Control & Code Review Testing Releasing

Slide 19

Slide 19 text

Source Control ▪ A single tree ▪ Hundreds of thousands of files ▪ Millions of lines ▪ > 2 commits/day ▪ Original source control not scaling ▪ Moving to Mercurial ▪ Easy to extend

Slide 20

Slide 20 text

Mercurial Contributions ▪Contributed >1000 patches ▪Hosted the past 2 Mercurial sprints ▪Open Sourced ▪ hgwatchman ▪ remotefilelog

Slide 21

Slide 21 text

Watchman and Mercurial ▪Watchman quickly answers “Which files have changed?” status diff checkout commit hg hgwatchman

Slide 22

Slide 22 text

Large Repos Are Slow ▪Lots of commits a day ▪ Pulls are slow ▪ Checkouts are slow ▪Years of history ▪ Clones are slow ▪ Requires lots of disk space ▪Impacts developers and build infrastructure

Slide 23

Slide 23 text

remotefilelog to the Rescue! rebase (p75) pull (p90) clone hg remotefilelog

Slide 24

Slide 24 text

Phabricator

Slide 25

Slide 25 text

Phabricator: Image Macros

Slide 26

Slide 26 text

Source Control & Code Review Testing Releasing

Slide 27

Slide 27 text

Unit Integration End-to-end Manual Types of Tests

Slide 28

Slide 28 text

https://flic.kr/p/jaYTYe Unit Testing: JUnit and Robolectric

Slide 29

Slide 29 text

https://flic.kr/p/7TMfGf End to End: Selendroid

Slide 30

Slide 30 text

Build 
 Slave COMMANDS Build 
 Slave Build Master COMMANDS STATUS Repository • Subversion • Mercurial • Bazaar • Darcs • GIT • CVS CHANGES POLL Notifiers • Email • Web Status • IRC • Status Client Continuous Builds: Buildbot

Slide 31

Slide 31 text

Source Control & Code Review Testing Releasing

Slide 32

Slide 32 text

Android Release Process 4 weeks of development 4 weeks of development 3.5 weeks of stabilization RC Master Release branch

Slide 33

Slide 33 text

https://flic.kr/p/kAT3Ba “Manual” Testing: Dogfood, Alpha and Beta

Slide 34

Slide 34 text

No content