Android Performance Improvements for Slideshare

Keerthi Korrapati
6 min readintermediate
--
View Original

Overview

The article discusses performance improvements made to the Slideshare Android application, focusing on optimizations in image loading, JSON parsing, and data model storage. These enhancements aimed to create a smoother, crash-free user experience, especially on low-end devices.

What You'll Learn

1

How to optimize image loading in Android applications

2

Why using a key-value store like SnappyDB can improve data retrieval speed

3

How to implement efficient JSON parsing using LoganSquare

Prerequisites & Requirements

  • Basic understanding of Android development and memory management
  • Familiarity with image loading libraries and JSON parsing techniques(optional)

Key Questions Answered

What optimizations were made to improve image loading in the Slideshare app?
The article describes the development of an in-house image loading library that uses intelligent bitmap pooling and recycling strategies. This library addresses memory issues encountered with existing libraries like Picasso and Glide, particularly on low-end devices, leading to a smoother user experience.
How does LoganSquare improve JSON parsing performance in the app?
LoganSquare was chosen for its compile-time annotation processing, which avoids the performance overhead of reflection used in other libraries like Jackson. This results in faster and more memory-efficient JSON parsing, crucial for handling large and nested payloads.
What were the performance metrics achieved after the optimizations?
The optimizations led to a 47% reduction in regular memory usage, a 40% decrease in peak memory usage, and a 92% reduction in GC_FOR_ALLOC pauses. Additionally, JSON parsing time was reduced by 15% for large payloads, contributing to a crash-free experience for 99.9% of users.

Key Statistics & Figures

Regular memory usage reduction
47%
Measured over time using the Memory Monitor tool.
Peak memory usage reduction
40%
Measured during application performance testing.
GC_FOR_ALLOC pauses reduction
92%
Significantly improved responsiveness during memory allocation.
JSON parsing time reduction
15%
For large JSON payloads after implementing LoganSquare.
Crash-free experience
99.9%
Percentage of users experiencing no crashes after optimizations.

Technologies & Tools

Database
Snappydb
Used as a key-value store to improve data retrieval speeds.
Library
Logansquare
Chosen for efficient JSON parsing with compile-time annotation processing.
Library
Bitmapfactory
Utilized for bitmap memory management and recycling strategies.

Key Actionable Insights

1
Implementing an in-house image loading library can significantly reduce memory issues in Android apps.
This approach allows for tailored optimizations that existing libraries may not provide, especially when dealing with high-resolution images on devices with limited resources.
2
Switching from SQLite to a key-value store like SnappyDB can enhance data retrieval speeds.
As applications scale, the overhead of transactions in SQLite can become a bottleneck. Using a key-value store eliminates this overhead, making it ideal for applications with complex data requirements.
3
Utilizing compile-time annotation processing for JSON parsing can improve performance and reduce errors.
By avoiding reflection, developers can achieve faster startup times and lower memory usage, which is particularly beneficial in mobile environments where resources are constrained.

Common Pitfalls

1
Relying solely on existing image loading libraries can lead to memory issues and UI stutters.
Many libraries do not handle large image datasets efficiently, especially on low-end devices, leading to performance degradation. Custom solutions may be necessary to meet specific app requirements.
2
Using reflection for JSON parsing can cause performance bottlenecks.
Reflection is slow and can lead to increased memory usage, especially in mobile applications where performance is critical. Compile-time solutions are preferred for better efficiency.

Related Concepts

Image Loading Optimization Techniques
JSON Parsing Strategies
Key-value Storage Solutions