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

[ad_1]


Posted by Ben Trengrove, Android Developer Relations Engineer

At present, as a part of the Compose August ‘23 Invoice of Supplies, we’re releasing model 1.5 of Jetpack Compose, Android’s fashionable, native UI toolkit that’s utilized by apps equivalent to Play Retailer, Dropbox, and Airbnb. This launch largely focuses on efficiency enhancements, as main elements 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 have been targeted on getting the API floor proper to offer a strong basis to construct on. We needed a strong and expressive API that was simple to make use of and secure in order that builders may confidently use it in manufacturing. As we proceed to enhance the API, efficiency is our high precedence, and within the August ‘23 launch, we’ve landed many efficiency enhancements.

Modifier efficiency

Modifiers see giant efficiency enhancements, as much as 80% enchancment to composition time, on this launch. One of the best half is that, because of 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.

We now have a collection of benchmarks which might be used to observe for regressions and to tell our investments in bettering efficiency. After the preliminary 1.0 launch of Compose, we started specializing in the place we may make enhancements. The benchmarks confirmed that we have been spending extra time than anticipated materializing modifiers. Modifiers make up the overwhelming majority of a composition tree and, as such, have 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 stage module, Compose UI. Modifiers construct on high of one another so we began migrating our low stage modifiers in Compose Basis within the subsequent launch, March ‘23. This included graphicsLayer, low stage focus modifiers, padding, and offset. These low stage 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 true beneficial properties would come once we may migrate the upper stage modifiers and composables themselves to the brand new modifier system.

Within the August ‘23 launch, we’ve 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 comprise clickable components 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 coated within the unique refactor and added a new API to create Modifier.Node components that eat CompositionLocal cases.

We are actually engaged on documentation to information you thru migrating your individual modifiers to the brand new Modifier.Node API. To get began instantly, you’ll be able to reference the samples in our repository.

Be taught extra in regards to the rationale behind the modifications within the Compose Modifiers deep dive discuss from Android Dev Summit ‘22.

Reminiscence

This launch consists of numerous enhancements in reminiscence utilization. We now have taken a tough take a look at allocations taking place throughout completely different Compose APIs and have decreased the entire allocations in numerous areas, particularly within the graphics stack and vector useful resource loading. This not solely reduces the reminiscence footprint of Compose, but additionally straight improves efficiency, as we spend much less time allocating reminiscence and scale back rubbish assortment.

As well as, we fastened a reminiscence leak when utilizing ComposeView, which is able to profit all apps however particularly people who use multi-activity structure or giant 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 acquire of 22% to preliminary composition time and as much as a 70% acquire in a single benchmark of advanced layouts involving textual content.

Various Textual content APIs have additionally been stabilized, together with:

Enhancements and fixes for core options

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

  • LazyStaggeredGrid is now secure.
  • Added asComposePaint API to exchange toComposePaint because the returned object wraps the unique android.graphics.Paint.
  • Added IntermediateMeasurePolicy to assist lookahead in SubcomposeLayout.
  • Added onInterceptKeyBeforeSoftKeyboard modifier to intercept key occasions earlier than the delicate keyboard.

Get began!

We’re grateful for the entire bug studies and have requests submitted to our subject 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? Try our roadmap to see the options we’re at the moment eager about and dealing on. We are able to’t wait to see what you construct subsequent!

Joyful composing!



[ad_2]

Leave a comment