Saturday, September 23

Posted by Serban Constantinoscu, Product Manager

Wouldn’t it be great if every update improved your app’s startup time, performance speed, and memory usage? Google Play System Update for Android Runtime (ART) does the same. These updates provide performance improvements, the latest security fixes, and unify core OpenJDK APIs on hundreds of millions of devices, all Android 12+ devices, and soon Android Go.

ART is the engine behind the Android operating system (OS). It provides the runtime and core APIs that all applications and most operating system services rely on. Both Java and Kotlin are compiled to bytecode by ART. Improvements in the process, compiler, and core API will benefit all developers by making application execution faster and bytecode compilation more efficient.

While Android components can be customized by device manufacturers, ART is the same for all devices and Google Play system updates enable ways to modify modules.

Adjusting the operating system

Android was originally designed for monolithic development, meaning that operating system components should not have clear API boundaries. This is because all dependent software is built together. However, this made it difficult to update ART independently of the rest of the operating system. Our first challenge was to resolve ART’s dependencies and create clear, well-defined and tested API boundaries. This allowed us to modify ART and make it self-updating.

An illustration of a racing car with the engine body hovering above the hood.  The curved arrow indicates where this part should go

As an integral part of the operating system, ART had to blaze new trails and engineer new operating system boundaries. These new borders are so extensive that adding and updating them will be very time-consuming. So we implement auto-generation in the build system.

READ :  You think Samsung can deliver a Snapdragon beater

Another example is the resolve stack, which records the actions taken at the end when a problem is encountered. Before changing the OS, all the stack unlock code is built together and can be changed on Android versions. This made the transition even more challenging, as there is only one version of ART to be ported to multiple versions of Android, so we had to create a new API boundary and design it to be forward compatible with new versions of ART APEX. Mod on devices that are no longer receiving full OS updates.

Recently, for Android 14, we improved the interface between ART and Package Manager, the service that decides how to install and update apps. This moves the operating system boundary from the ART dex2oat command line to a well-defined interface, allowing future optimizations, such as fine-tuning control of configuration mode.

Modernization of ART has introduced new challenges. For example, a set of Java libraries, called the boot classpath, had to be securely patched to ensure optimal performance. This needs to introduce a new safe mode that compiles on boot as well as a backward GIT compilation mode.

On older devices, a secure setup occurs on the first reboot after an ART update. On newer devices that support the Android Virtualization Framework, the scan is performed while the device is idle, in an isolated cluster – saving up to 20 seconds of boot time.

Testing the ART APEX module

The ART APEX module is a complex software that contains more APIs than any other APEX module. It also supports a quarter of the developer APIs available in the Android SDK. Additionally, ART has a compiler that aims to get the most out of the underlying hardware by generating chipset-based instructions, such as Arm SVE. This, along with the multiple operating system versions that the ART APEX module runs on, makes testing challenging.

READ :  All Amazon Halo devices will stop working this year

First, we adapted the test framework to a module from a platform release (eg Android CTS). We did this by introducing an ART-specific Mainline Test Suite (MTS), collecting code coverage statistics for both compiler and runtime as well as core OpenJDK APIs.

Our goal is 100% API coverage and top line coverage, especially for new APIs. Along with HWASan and fuzzing, all of the above-mentioned tests contribute to a massive test load that needs to be shared across multiple devices to ensure they are completed in a reasonable amount of time.

An example of a modularized test framework

We test upcoming ART releases by gathering over 18 million APKs and running app compatibility tests and replicating launch, performance, and memory metrics on a variety of Android devices as closely as possible. Once the tests have passed with all compilation modes, all garbage collector algorithms and supported OS versions, we will start rolling out the next release of ART gradually.

Benefits of ART Google Play system update

By only updating ART with OS updates, users get the latest performance improvements and security fixes as soon as possible, while developers get OpenJDK updates and compiler updates that benefit both Java and Kotlin.

As shown in the graph below, runtime and compiler optimizations in ART 13 have led to real-world app launch improvements of up to 30% on some devices.

A graph of average app launch times in milliseconds with up to a 30% improvement over 12 weeks on devices running the latest ART Google Play system update.

ART updates allow us to deploy fixes more frequently with little extra effort from our ecosystem partners. They include distributing OpenJDK patches to Android devices as soon as possible, as well as runtime and compiler security fixes such as CVE-2022-20502 found through automated patching tests.

READ :  Google has rolled out a fix for the Pixel Buds A-Series pairing bug

For developers, ART updates mean they can now target the latest programming features. ART 13 introduces OpenJDK 11 core language features, making it the fastest new OpenJDK release ever on Android devices.

What’s next?

We will release ART 14 for all compatible devices in the coming months. ART 14 includes OpenJDK 17 support with new compiler and runtime improvements and performance by reducing code size. Stay tuned for more information on ART 14!

Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.


Robert is an expert in Android mobile phones. He has been using Android phones since they first came out, and he has been following the development of the platform closely. He has written many articles and tutorials on Android phones, and he is always up-to-date on the latest news and developments in the world of Android.