Building fb mobile


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Building fb mobile

  1. 1. developersPrashant Sridharan and Bear Douglasgithub/coolasspuppygithub/beardouglas@coolasspuppy@beardigsitBuilding Facebook’s Native AppsTuesday, May 7, 13
  2. 2. Agenda▪ “Over the wall”: some history▪ Product Teams and the Core Team▪ Scheduling and Stabilizing Releases▪ How We Develop▪ Eating the Dogfood: Builds▪ A Culture of Unit Testing▪ Future of iOS at FacebookTuesday, May 7, 13
  3. 3. HistoryTuesday, May 7, 13
  4. 4. Facebook for Mobile▪ Web deeply engrained in Facebook’s DNA▪ Use HTML5/Javascript within “wrapper” native app▪ Developed our own framework for advanced integration(image uploads, photo browsers, mixing native/web elements)Tuesday, May 7, 13
  5. 5. HTML as an app platform▪ What does it bring us?One CodebaseInstant Updates A/B TestingTuesday, May 7, 13
  6. 6. HTML as an app platform▪ Frequent performance problems▪ No coherent multithreading strategy in web apps▪ DOM manipulations and layout can spin out of control, lots of hacks▪ Difficult memory management (<img>)▪ Debugging and getting stack traces are extremely difficult▪ Limited animations and effectsTuesday, May 7, 13
  7. 7. A few good engineers▪ Facebook for iOS 5.0 began as an experiment▪ Could we achieve better results with native code?▪ High barrier: rewrite all of Facebook’s mobile UI!▪ Couldn’t disrupt company▪ Move this to a war room!Tuesday, May 7, 13
  8. 8. Winding Road▪ Lots of changes along the way:▪ Led to a rethink about how our APIs fetch data▪ Experimented with advanced rendering to make feed smooth▪ Sprinkle in some design changes▪ Plenty of wrangling with Core Data and Core Animation▪ Shipped internally starting in mid-2012▪ Reaction: we liked it…Tuesday, May 7, 13
  9. 9. Reaction▪ Press loved it▪ More importantly…▪ Perceived Speed way up▪ User Ratings way up▪ 2x Speed increase!Tuesday, May 7, 13
  10. 10. TeamTuesday, May 7, 13
  11. 11. Scaling it Up▪ We got it out the door, but…▪ A few iOS engineers in a room won’t cut it▪ Making Facebook a “mobile first” companyTuesday, May 7, 13
  12. 12. Wake-up Call▪ News Feed team invented phenomenal new story type▪ … but they weren’t thinking about 5.0▪ … and we didn’t know about News Feed developments▪ Mad dash to port the story type to native code before 5.0▪ Not an experience we wanted to repeat!▪ Lots of cooperation required to keep abreast of product developments:news feed, timeline, comments, photos, pages, places, events, …Tuesday, May 7, 13
  13. 13. Prioritization and resources▪ Every product wanted their features in the new native app▪ Overwhelmed by prioritizing so many requests▪ iOS Team still had very limited resourcesTuesday, May 7, 13
  14. 14. A multi-app ecosystemTuesday, May 7, 13
  15. 15. The Team SandwichRelease Team: Release & Stabilization ProcessRelease Team: Release & Stabilization ProcessRelease Team: Release & Stabilization ProcessRelease Team: Release & Stabilization ProcessRelease Team: Release & Stabilization ProcessPhotos Feed Search Places MessagesCore Team: Shared LibrariesCore Team: Shared LibrariesCore Team: Shared LibrariesTuesday, May 7, 13
  16. 16. Core Team: support and assist▪ Build core, shared libraries▪ Infrastructure and integration▪ Keep the app fast and cleanTuesday, May 7, 13
  17. 17. Product CycleTuesday, May 7, 13
  18. 18. Timing Releases▪ Simple model: Release X will have features A, B, C▪ Next release at mercy of the slowest product team▪ No choice but to wait until it’s “done”▪ This slowed us down, and we want to move fastTuesday, May 7, 13
  19. 19. Fixed Release Cycle▪ Ship an update every x weeks▪ … no matter whatAt Facebook we target a release every4 weeks (approximately)Tuesday, May 7, 13
  20. 20. Building features with an “off switch”▪ Every feature must be built with a way toturn it off▪ If a feature destabilizes the build or isn’tcomplete, turn it off and try again nexttime▪ #defines – or runtime switches(preferred)Tuesday, May 7, 13
  21. 21. Road to a new “Like Bar”Tuesday, May 7, 13
  22. 22. DevelopmentTuesday, May 7, 13
  23. 23. Process▪ Engineers make changes locally▪ Submit changes for review▪ Changes are automatically checked for build and unit test failures▪ Team members review & suggest changes▪ Once approved, submit to masterTuesday, May 7, 13
  24. 24. Source Control: Git▪ Distributed development▪ Designed for speed▪ Open source▪ Optimized for non-linear development▪ Allows local branchingTuesday, May 7, 13
  25. 25. PhabricatorTextTuesday, May 7, 13
  26. 26. Arcanist▪ The command line counterpart to Phabricator▪ arc lint▪ Checks for common errors:▪ Null pointers▪ Syntax errors and style guideline violations▪ Using APIs unavailable in all supported Android versions▪ arc land▪ Pushes code into the treeTuesday, May 7, 13
  27. 27. BuildbotTuesday, May 7, 13
  28. 28. BuildsTuesday, May 7, 13
  29. 29. Downloading builds▪ Deployed to entire company▪ Signed with Enterprise Distribution profile▪ Daily builds posted to internal web site▪ Installed directly on device▪ Use different Bundle IDs for different buildsTuesday, May 7, 13
  30. 30. Tuesday, May 7, 13
  31. 31. Rage Shake▪ Take out your stress on the device▪ Captures:▪ Screen shot (with annotations!)▪ Network logs▪ Last crash log▪ Last x-seconds of logging▪ Dumps the view hierarchy▪ Automatically files a bug and sends it to FacebookTuesday, May 7, 13
  32. 32. Branching▪ Two concurrent branches:▪ Master▪ Engineers make progress on future features▪ All changes checked in here first▪ …including bug fixes for Releases▪ Release▪ Once verified in Master…▪ …“Release team” pulls them into Release branchTuesday, May 7, 13
  33. 33. TestingTuesday, May 7, 13
  34. 34. Testing is important to Facebook▪ Not in Facebook’s culture:▪ SDEs “in Test”▪ Large QA departments▪ Definitely in Facebook culture:▪ High quality, reliable user experience▪ We believe in developer-authored unit testsTuesday, May 7, 13
  35. 35., May 7, 13
  36. 36. Unit Testing on iOS▪ Some built-in Xcode support:▪ OCMock & SenTestingKit▪ Uses dynamic nature of Objective-C▪ Easy to set-up, and well documented▪ BUT▪ Many iOS engineers unfamiliar with testing▪ Frameworks are immature▪ Incomplete support in xcodebuild▪ Doesn’t understand “Test” action in your Schemes▪ Can’t run tests that require SimulatorTuesday, May 7, 13
  37. 37. xctool▪ Replacement for ‘xcodebuild’▪ Runs Simulator tests▪ Structured output▪ Phabricator support built-in▪ Customizable to other build systemsTuesday, May 7, 13
  38. 38. Tuesday, May 7, 13
  39. 39. Tuesday, May 7, 13
  40. 40., May 7, 13
  41. 41. We needed a better tool▪ Minimal overhead in creating a module▪ Keep boilerplate out of the codebase▪ IDE friendly▪ Faster clean builds▪ Faster incremental builds▪ Support ad-hoc build stepsTuesday, May 7, 13
  42. 42. Buck: an Android build system▪ build rule procedure for producing output files from input files▪ build file file (named BUCK) where build rules are declared▪ build target string identifier for a build ruleTuesday, May 7, 13
  43. 43. Build Target//java/com/facebook/share:uiRoot of the repositoryDirectory where the build file can be foundName of the build ruleTuesday, May 7, 13
  44. 44. Build Ruleandroid_library(name = ui,srcs = glob([**/*.java]),deps = [//android_res/com/facebook/share:res,//java/com/facebook/base:base,//third-party/java/guava:guava,],visibility = [ PUBLIC ],)Tuesday, May 7, 13
  45. 45. Build File: Rules and MacrosTuesday, May 7, 13
  46. 46. Dependency GraphAR ARARALAL ALAL ALALABGRABGRTuesday, May 7, 13
  47. 47. Dependency GraphAR ARARALAL ALAL ALALABGRABGRTuesday, May 7, 13
  48. 48. How does IntelliJ feel about all of this?buck project FTW!Tuesday, May 7, 13
  49. 49. Focus on Speed▪ Parallel builds▪ Unit tests take 4 minutes instead of 20 by using 8 threads▪ Incremental▪ Only rebuild what is necessaryTuesday, May 7, 13
  50. 50. Migration: August 2012AntBuck3m40s1m30sTuesday, May 7, 13
  51. 51. open source:xctool and Buck, May 7, 13
  52. 52. Future of Mobile @ FacebookTuesday, May 7, 13