Analysis of the Facebook.app for iOS [v. 87.0]

Posted: April 10th, 2017 | Author: | Filed under: Analysis, Debugging, iOS, Programming | Tags: , | 16 Comments »

6 months ago I analyzed the version 66.0 of the Facebook.app for iOS:
http://blog.timac.org/?p=1303

The version 66.0 was a 165 MB app on an iPad Air 2 (64-bit). It was a monolithic app with its main binary being more than 100 MB.

The version 87.0 is now available: 253 MB on the same iPad Air 2 with only 64-bit code. In just 6 months, the Facebook.app size grew by 88 MB!


Download Info

Let’s see what changed…

App content

Looking at the app content of the version 87.0 using GrandPerspective gives a good overview:


Facebook 87.0 content

Here is how the content of the version 66.0 looked like:


Facebook 66.0 content

As you can see, the Facebook.app has been completely restructured:

  • the main binary is now only 19 MB
  • there is a huge 136 MB framework ‘FBSharedFramework’
  • there is another 26 MB framework called ‘FBNotOnStartupPathFramework’

Duplicated resources

One of the reason the app size grew is due to multiple copies of the same resources inside the app.

unetshallow_init.pb

You can actually see in the previous screenshot 3 copies of the same file ‘unetshallow_init.pb’:

  • Facebook.app/Frameworks/FBNotOnStartupPathFramework.framework/opticalflow_resource/unetshallow_init.pb
  • Facebook.app/Frameworks/FBSharedFramework.framework/opticalflow_resource/unetshallow_init.pb
  • Facebook.app/opticalflow_resource/unetshallow_init.pb


unetshallow_init

Keeping only one copy would save 7.2 MB.

DataFiles

Similarly the DataFiles folder appears 3 times. Keeping a single copy would save around 2 MB:

  • Facebook.app/DataFiles/
  • Facebook.app/Frameworks/FBNotOnStartupPathFramework.framework/DataFiles/
  • Facebook.app/Frameworks/FBSharedFramework.framework/DataFiles/


DataFiles

FBFacecastTipJarResources

Some resources called ‘FBFacecastTipJarResources’ appear to be duplicated no less than 6 times in the app! The ‘FBFacecastTipJarResources’ resources only take 150 KB on disk but 6 times makes 900 KB.

One example:

  • Facebook.app/FBFacecastTipJarResources/sent.m4a
  • Facebook.app/Frameworks/FBNotOnStartupPathFramework.framework/FBFacecastTipJarResources/sent.m4a
  • Facebook.app/Frameworks/FBNotOnStartupPathFramework.framework/sent.m4a
  • Facebook.app/Frameworks/FBSharedFramework.framework/FBFacecastTipJarResources/sent.m4a
  • Facebook.app/Frameworks/FBSharedFramework.framework/sent.m4a
  • Facebook.app/sent.m4a

Other duplicated resources

There are a bunch of other duplicated resources, amongst them:

  • modelMetaData.bin: 4 * 1 MB
  • schemaMetaData.bin: 4 * 830 KB
  • FBCommunicationSoundKit.bundle: 3 * 741 KB
  • MNSounds.bundle: 3 * 528 KB
  • FBSoundControllerResources: 3 * 500 KB
  • RelaySchema.json: 3 * 319 KB
  • libPhoneNumber.bundle: 3 * 172 KB
  • CACerts.plist: 3 * 168 KB
  • FBFacecastBroadcastKitResources: 3 * 98 KB
  • Montserrat-SemiBold.ttf: 3 * 70 KB
  • ReactMobileConfigMetadata.json: 3 * 33 KB
  • FBEntityCardsModuleResources: 3 * 33 KB
  • add-photo@2x.jpg: 3 * 29 KB
  • FBFacecastWithKitResources: 3 * 20 KB
  • FBNativeArticleEngagementActionsResources: 3 * 20 KB
  • FBFeedbackReactionsKitResources: 3 * 12 KB

These listed resources count for 15.5 MB. By removing the duplicated resources, you could save at least 10 MB.

Duplicated images

The Facebook.app contains 3 assets.car files:

  • Facebook.app/Assets.car: 11.3 MB for 2267 items
  • Facebook.app/Frameworks/FBNotOnStartupPathFramework.framework/Assets.car: 10.3 MB for 2126 items
  • Facebook.app/Frameworks/FBSharedFramework.framework/Assets.car: 9.5 MB for 1972 items


assets

All the 1972 images in FBSharedFramework are inside the main Assets.car and also part of the FBNotOnStartupPathFramework Assets.car. So there are 3 times the same 1972 images taking 3 * 9.5 MB = 28.5 MB.

Keeping a single set of these 1972 images would save 19 MB.

The remaining images in the main Assets.car (2267 – 1972 = 295) and in the FBNotOnStartupPathFramework Assets.car (2126 – 1972 = 154) are unique.

New localizations

The Facebook.app gained 5 new localizations, increasing the app size by 4.2 MB:
hi.lproj (1.3 MB)
hr.lproj (692 KB)
hu.lproj (750 KB)
ro.lproj (709 KB)
sk.lproj (713 KB)

Also each localization got a new 12 KB file called ‘AdsCountriesConfig.json’. This adds 336 KB.

DO_NOT_USE_OR_YOU_WILL_BE_FIRED

When analyzing the version 66.0 I completely missed some amusing Objective-C interfaces, protocols and methods:

@protocol FBDeprecatedAppModule_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
@protocol FBLoginFacilitatingAppModule
@interface FBTimelineModule : FBNativeAppModule_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
@interface FBNotificationsModule : FBNativeAppModule_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
@interface FBProductionLockoutModule : FBNativeAppModule_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
@interface FBSearchModule : FBNativeAppModule_DO_NOT_USE_OR_YOU_WILL_BE_FIRED

__RODATA segment

Although the main binary is much smaller than the App Review limitation, the Facebook.app still uses a __RODATA segment containing sections generally found inside the __TEXT segment. For more information about it, please look at the previous post http://blog.timac.org/?p=1303.

Conclusion

Between version 66.0 and 87.0, the Facebook.app has been completely restructured. The main -and only- binary has been split in several frameworks.

It appears however that during this process a couple of resources have been unnecessarily duplicated:

  • opticalflow_resource: 3 * 3.6 MB
  • DataFiles: 3 * 1 MB
  • images: 3 * 9.5 MB
  • FBFacecastTipJarResources: 750 KB
  • Other duplicated resources: 15.5 MB

Removing the duplicated resources would save at least 40 MB. This partially explains why the app size has increased by 90 MB.

Update 15.04.2017: Facebook.app for iOS [v. 88.0] cleans up duplicates


16 Comments on “Analysis of the Facebook.app for iOS [v. 87.0]”

  1. 1 David Emery said at 6:36 pm on April 10th, 2017:

    But I’m sure they’re using Agile Development, so it’s OK.

  2. 2 Jean-Daniel said at 7:07 pm on April 10th, 2017:

    This is the price to pay to get so wonderful new features. Wait, there is 0 new feature …

  3. 3 Rob said at 7:58 pm on April 10th, 2017:

    Please do messenger… since it is now a crazy mutant of so many apps… dupes beware.

  4. 4 EricS said at 8:33 pm on April 10th, 2017:

    This is what happens when your development team is too big and you have a policy of updating your app every two weeks for no particular reason.

  5. 5 Fede777 said at 8:39 pm on April 10th, 2017:

    Besides the size of the full app, what happened to Delta updates for iOS apps?

  6. 6 Timac said at 9:02 pm on April 10th, 2017:

    Delta updates are supported and done by Apple automatically. You can read more information about it here:
    https://developer.apple.com/library/content/qa/qa1779/_index.html

  7. 7 Whiteboard Hater said at 12:14 am on April 11th, 2017:

    Hey Facebook – it is time to stop whiteboard coding during the interview.

  8. 8 Clown Boy said at 1:04 am on April 11th, 2017:

    What in tarnation…

  9. 9 Jon said at 1:31 am on April 11th, 2017:

    An analysis of what’s in the FBSharedFramework would be very interesting.

  10. 10 Lloyd said at 2:22 am on April 11th, 2017:

    worth pointing out that this is larger than any of the Microsoft giants – Word, Excel, Powerpoint.

  11. 11 Henrik said at 10:30 am on April 11th, 2017:

    @2

    I would like to see Messenger and Groups.
    And maybe see if there is references of Facebook inside Instagram.

  12. 12 Håvard Pedersen said at 12:03 pm on April 11th, 2017:

    As a user of a 16 GB iPhone, the size of the Facebook app (including its terribly large data cache) forced me to uninstall it and use the web version instead.

    I have also noticed the Instagram app being victim of the same terrible space usage.

  13. 13 Todd B said at 12:10 am on April 12th, 2017:

    The iPhone 7’s version 87 is even worse at 391 MB

  14. 14 KenM said at 3:42 am on April 15th, 2017:

    Maybe they heard you? I just saw the 88.0 update pop up on my iPad Air 2 and it’s “only” 218 mb now.

  15. 15 Timac said at 8:40 am on April 15th, 2017:

    A new post is available: Facebook.app for iOS [v. 88.0] cleans up duplicates

  16. 16 Tony said at 9:23 pm on April 15th, 2017:

    Google and Facebook are web companies, they fail when making desktop / mobile apps.

    They really don’t understand software development / engineering.

    Website != App


Leave a Reply