Interview Road (5)-Ali face question Android network picture loading optimization

Source: Internet
Author: User
Tags webp
Topic:

When the network is bad, how to optimize the load picture of the network when stalling?

Ideas:

Consider both the loading of the picture itself and the storage of the phone

Workaround: 1. Find a replacement for an existing picture format

In a number of image formats, Google's WEBP is selected. 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 images according to the ability of the device to process pictures

Previously, all images were uniformly loaded with the maximum resolution, so that the user was free to 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. Adjust the policies for caching and reusing pictures.

Use the phone's cache to cache frequently used images, such as the home page image, and the often-opened image setting algorithm.

4. Optimize Network Requests

Use Okhttp. OkHttp supports faster retries under a bad network environment and can also use the SPDY protocol for Fast Concurrent network requests.
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.
Reference: https://greenrobot.me/devnews/facebook-engineer-improve-android-app/

Interview Road (5)-Ali face question Android network picture loading optimization

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.