How Facebook engineers are improving their Android client's

Source: Internet
Author: User
Tags webp

from://http://greenrobot.me/devnews/facebook-engineer-improve-android-app/

How Facebook engineers are improving their Android client's

This article comes from the Facebook engineer blog.

As the world's largest social network, Facebook's Android client faces a wide variety of environments, such as geography, Android devices, and mobile networks. For this reason, Android product managers and engineers went to Africa in 2013 to test the performance of their own Android clients in developing countries. I was a little bit weird when I saw the news, and later I saw the blog to understand why they did it.

This group of Facebook engineers came to Africa and used the latest version of Facebook's Android client locally. The results of the tests really impressed them:

    1. The local network environment is very bad and the app often interrupts the network connection.
    2. The local people use a small amount of Android device memory, causing the app to load slowly and often crashes.
    3. Their monthly traffic ran out within 40 minutes.

After this impressive test, Facebook engineers began a series of optimizations for their Android clients.

Performance optimization

This is mainly to improve the performance of the app on the low-end machine.

    • Problem: Single-core Android phones are slower to start on Facebook because the app initializes multiple modules in parallel at startup.
      Solution: Delay These initialization processes on a single-core phone and start initializing the module even when a module is being used.
    • Problem: The information flow is slow to load when the network environment is poor.
      Solution: Grab the traffic data from the server as early as possible, use more time to establish the connection, and download the content of the information flow.

The end result is a 50% reduction in app startup time.

optimization of data processing efficiency

The journey in Africa has led engineers to find that traffic is expensive in developing countries, and that a photo of Facebook's important experience is a big part of the flow, so the engineers decided to move the knife into the app's photos in order to get people to enjoy Facebook without worrying about traffic:

    1. Find replacements for existing picture formats. Through the research of engineers, in many image formats, the last engineer chose Google's webp. The reason for this is simple: high compression efficiency and good support for Android (Google, after all). After using WebP, the traffic is nearly 25% to 35 compared to the JPG format, and the traffic is nearly 80% compared to PNG-formatted images. The most important thing is that the image quality has not changed after using WEBP.
    2. Load pictures According to the ability of the device to process pictures. Prior to that, Facebook's app was a uniform loading of images with the highest resolution, so that users could freely zoom in and out of the picture. Later, the app's first loaded image size fits the image window size. If thumbnails are needed, the app loads only thumbnail-sized images, users need higher-resolution images, apps can load, and previously uniformly loaded images with the highest resolution.
    3. Policies that adjust the caching and reuse of pictures. The engineers tested different cache strategies, different cache sizes, and finally synthesized the optimal scheme.

The final result is a 50% reduction in traffic costs.

Network optimization

Because of the poor network environment in many regions, which has made the experience of Facebook's app so bad, engineers have also improved the efficiency and reliability of the app's network.

    1. Use Okhttp.  Facebook started using the Okhttp (an open-source network protocol stack) developed by Square, and now Google is using okhttp as the default for HttpURLConnection from Android 4.4. OkHttp supports faster retries under a bad network environment and can also use the SPDY protocol for Fast Concurrent network requests.
    2. Use Okhttp to adjust the image's pre-fetch algorithm to ensure that the image in front of the download queue in the app is prioritized, preventing the queue from being blocked for too long.

After optimization, the image load is slow or the load failed feedback is nearly 90% less.

App File size optimization

Engineers in Africa found that people use the largest number of mobile phone disk space is very small, which means that the user upgrade barriers, and can infer that these people because of the space problem of mobile phones have been using the old version of the app, then they will not be able to upgrade to enjoy the previously mentioned optimized app experience. So engineers started working on how to optimize the app file size:

    1. Use the features offered by Google Play to provide different installation files for different Android versions, different Android screen resolution phones. This allows for functional tradeoffs on different devices.
    2. In this process, of course, monitoring tools and test tools are required to ensure that the app's functionality is normal after optimizing the app file size. Now Facebook engineers have developed a set of spaces that can calculate how much each feature contributes to Facebook's Android app.

The optimized file size is reduced by nearly 65%.

Reflection

The Facebook engineers ' journey to Africa has made them more aware of the mobile app performance, the effectiveness of data processing, the reliability of the network, and what the app's file size means for the mobile market in developing countries.

Since then, engineers have been testing each and every aspect of the app's new features, and Facebook has a set of tools to directly get feedback from users about these features, and engineers are beginning to extend these practices to Messenger and Instagram Android App.

How Facebook engineers are improving their Android client's

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.