What’s new within the Jetpack Compose August ’23 launch



Posted by Ben Trengrove, Android Developer Relations Engineer

Right this moment, as a part of the Compose August ‘23 Invoice of Supplies, we’re releasing model 1.5 of Jetpack Compose, Android’s trendy, native UI toolkit that’s utilized by apps equivalent to Play Retailer, Dropbox, and Airbnb. This launch largely focuses on efficiency enhancements, as main components of our modifier refactor we started within the October ‘22 launch are actually merged.

Efficiency

After we first launched Compose 1.0 in 2021, we had been targeted on getting the API floor proper to offer a stable basis to construct on. We needed a robust and expressive API that was simple to make use of and steady in order that builders might confidently use it in manufacturing. As we proceed to enhance the API, efficiency is our prime precedence, and within the August ‘23 launch, we’ve got landed many efficiency enhancements.

Modifier efficiency

Modifiers see massive efficiency enhancements, as much as 80% enchancment to composition time, on this launch. The most effective half is that, due to our work getting the API floor proper within the first launch, most apps will see these advantages simply by upgrading to the August ‘23 launch.

Now we have a set of benchmarks which can be used to watch for regressions and to tell our investments in enhancing efficiency. After the preliminary 1.0 launch of Compose, we started specializing in the place we might make enhancements. The benchmarks confirmed that we had been spending extra time than anticipated materializing modifiers. Modifiers make up the overwhelming majority of a composition tree and, as such, had been the most important contributor to preliminary composition time in Compose. Refactoring modifiers to a extra environment friendly design started below the hood within the October ‘22 launch.

The October ‘22 launch included new APIs and efficiency enhancements in our lowest degree module, Compose UI. Modifiers construct on prime of one another so we began migrating our low degree modifiers in Compose Basis within the subsequent launch, March ‘23. This included graphicsLayer, low degree focus modifiers, padding, and offset. These low degree modifiers are utilized by different extremely utilized modifiers equivalent to Clickable, and are additionally utilized by many framework Composables equivalent to Textual content. Migrating modifiers within the March ‘23 launch introduced efficiency enhancements to these elements, however the actual beneficial properties would come once we might migrate the upper degree modifiers and composables themselves to the brand new modifier system.

Within the August ‘23 launch, we’ve got begun migrating the Clickable modifier to the brand new modifier system, bringing substantial enhancements to composition time, in some circumstances as much as 80%. That is particularly related in lazy lists that include clickable parts equivalent to buttons. Modifier.indication, utilized by Clickable, continues to be within the technique of being migrated, so we anticipate additional beneficial properties to return in future releases.

As a part of this work, we recognized a use case for composed modifiers that wasn’t lined within the authentic refactor and added a new API to create Modifier.Node parts that devour CompositionLocal situations.

We are actually engaged on documentation to information you thru migrating your personal modifiers to the brand new Modifier.Node API. To get began straight away, you may reference the samples in our repository.

Study extra in regards to the rationale behind the adjustments within the Compose Modifiers deep dive speak from Android Dev Summit ‘22.

Reminiscence

This launch contains quite a few enhancements in reminiscence utilization. Now we have taken a tough take a look at allocations taking place throughout totally different Compose APIs and have decreased the full allocations in quite a few areas, particularly within the graphics stack and vector useful resource loading. This not solely reduces the reminiscence footprint of Compose, but in addition straight improves efficiency, as we spend much less time allocating reminiscence and cut back rubbish assortment.

As well as, we mounted a reminiscence leak when utilizing ComposeView, which can profit all apps however particularly people who use multi-activity structure or massive quantities of View/Compose interop.

Textual content

BasicText has moved to a brand new rendering system backed by the modifier work, which has introduced a median of achieve of 22% to preliminary composition time and as much as a 70% achieve in a single benchmark of advanced layouts involving textual content.

A lot of Textual content APIs have additionally been stabilized, together with:

Enhancements and fixes for core options

Now we have additionally shipped new options and enhancements in our core APIs in addition to stabilizing some APIs:

  • LazyStaggeredGrid is now steady.
  • Added asComposePaint API to switch toComposePaint because the returned object wraps the unique android.graphics.Paint.
  • Added IntermediateMeasurePolicy to help lookahead in SubcomposeLayout.
  • Added onInterceptKeyBeforeSoftKeyboard modifier to intercept key occasions earlier than the smooth keyboard.

Get began!

We’re grateful for the entire bug stories and have requests submitted to our difficulty tracker — they assist us to enhance Compose and construct the APIs you want. Proceed offering your suggestions, and assist us make Compose higher!

Questioning what’s subsequent? Take a look at our roadmap to see the options we’re at present fascinated by and dealing on. We will’t wait to see what you construct subsequent!

Comfortable composing!



Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles