Mobile Development 12 min read

JD's Self‑Developed HarmonyOS Image Library (DImage): Architecture, Implementation, and Performance Optimizations

This article details JD's self‑built HarmonyOS image library (DImage), covering its background, research on existing solutions, C++‑based cross‑platform architecture, core modules, performance‑focused pipeline, monitoring and recovery mechanisms, and future optimization directions, all aimed at high‑performance image handling for the JD app on HarmonyOS.

JD Tech
JD Tech
JD Tech
JD's Self‑Developed HarmonyOS Image Library (DImage): Architecture, Implementation, and Performance Optimizations

Background

At the beginning of 2024 JD started developing a HarmonyOS version of its e‑commerce app. Because the app heavily relies on images, a high‑performance image library became a core capability in the first phase of JD's HarmonyOS infrastructure plan.

Technical Implementation

Research : Two native solutions were examined – the system Image component and the third‑party ImageKnife library. Both lacked the performance, extensibility, and monitoring needed for JD’s scale.

Decision to build in‑house : JD chose to develop a custom image library using C++ as the core to achieve cross‑platform reuse, better integration with the Taro Harmony framework, and superior runtime performance.

JDImage Capabilities

Architecture Design : A modular, layered architecture separates a C++‑based Core layer (cross‑platform) from platform‑specific client layers, allowing flexible substitution of modules and easier maintenance.

Core Modules :

Image Cache – memory (LRU) and disk caches with size limits and multithreaded I/O.

Image Data Source – supports HTTP (via Cornet) and Base64 sources.

Decoders – system decoder for common formats and an AVIF decoder built on libavif.

Performance Monitoring – tracks loading times, cache hit rates, and resource usage.

Image Component – wraps the system Image component, adding lazy loading, source size, and priority attributes.

Performance Optimizations

The loading pipeline borrows ideas from Fresco, allowing configurable sub‑tasks, thread scheduling with FFRT, duplicate request aggregation, and detailed load monitoring. Integration with JD’s image server enables automatic URL parameter injection for format conversion, resizing, and quality reduction, reducing network traffic.

Quality Assurance

Online monitoring and exception tracking assign unique error codes to each pipeline stage. Recovery mechanisms include pipeline retry, component fallback to the system Image component, and remote configuration‑driven degradation for specific devices or app versions.

Future Plans

Planned improvements cover network optimizations (weak‑network handling, HTTPDNS), higher cache reuse, GIF and low‑end device optimizations, deeper use of JD’s image server capabilities, expanded platform support (iOS, Android), and advanced image‑enhancement techniques such as super‑resolution and HDR.

Conclusion

JD’s self‑developed HarmonyOS image library, built with a modular C++ core and a flexible pipeline, resolves cross‑platform development challenges, delivers high performance and stability, and provides a solid foundation for future multi‑platform image handling.

Cross‑PlatformPerformance OptimizationHarmonyOSC++TaroImage Library
JD Tech
Written by

JD Tech

Official JD technology sharing platform. All the cutting‑edge JD tech, innovative insights, and open‑source solutions you’re looking for, all in one place.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.