Posted by: Ben TrengroveAndroid Developer Relations Engineer
Today, as part of the Compose January 2024 BOM, we’re releasing version 1.6 of Jetpack Compose, the latest native UI toolkit for Android used by apps like Threads, Reddit, and Dropbox. This release focuses on performance improvements as we continue to migrate modifiers and improve the efficiency of key parts of the API.
To use today’s release, upgrade your Compose BOM version to: 2024.01.00
Performance
Performance continues to be a top priority, and this release of Compose includes significant performance improvements across the board. We are looking at additional Scrolling performance improved by ~20% We see a ~12% improvement in startup time in our benchmark, and this is on top of the improvements in the August 2023 release. As with any given release, most apps can enjoy these benefits simply by upgrading to the latest version without any other code changes.
Improvements in scrolling performance and startup times are a result of our continued focus on memory allocation and lazy initialization to ensure that the framework performs work only when needed. These improvements can be found across all of Compose’s APIs, especially text, clickable, lazy list, and graphics APIs (including vectors), and are made possible in part by ongoing Modifier.Node refactoring work across multiple releases.
There are also new instructions for creating your own custom modifiers using Modifier.Node.
Configuring stability in external classes
Compose compiler 1.5.5 introduces a new compiler option that allows your app to provide configuration files that it considers stable. This option allows you to mark any class as stable, including your own modules, external library classes, and standard library classes, without having to modify the module or wrap it in a stable wrapper class. Standard stability agreements apply. This is another convenient way to tell the Compose compiler what your app should consider stable. For more information about how to use stability configurations, see our documentation.
Generated code performance
Code generated by the Compose compiler plugin has also been improved. Minor modifications to this code can significantly improve performance by generating code from all composable functions. The Compose compiler tracks Compose state objects to know which composables to reconfigure when their values ​​change. However, many state values ​​are read only once, and some are never read at all, but still change frequently! This update allows the compiler to skip tracing when it is not needed.
In Compose compiler 1.5.6, ’embedded memory’ is also enabled by default. This mode transforms remember At compile time, it takes into account the information you already have about the composable’s parameters that are used as keys. remember. This not only speeds up the computation to determine if a memorized expression needs to be re-evaluated, but also means that you can place breakpoints inside the expression. remember While debugging, the function may no longer be called. This is because the compiler removed the use of: remember And replaced it with other code.
Don’t skip composables
We’re also investing in automatically improving the performance of the code you write. We want to optimize the code we write to be intuitive, eliminating the need to dig deep into Compose internals to understand why a composable shouldn’t be recomposed.
This release of Compose adds support for an experimental mode called ”.Powerful skip mode“. Strong skip mode relaxes some of the rules about which changes can skip reconfiguration, bringing the balance in the direction developers expect. When strong skip mode is enabled, the same object instance is If passed, composables with unstable parameters can also skip reconstruction. Additionally, a strong skip mode will automatically remember lambdas for compositions that capture unstable values, in addition to the current default behavior of remembering lambdas using only stable captures. Strong skip mode is currently disabled by default as it is considered experimental and not yet ready for production use. We are evaluating its effectiveness before aiming to enable it by default in Compose 1.7. Strong skip mode Please refer to the instructions to help you experiment and find problems.
text
Change default font padding
In this release includeFontPadding environment lie Basically. includeFontPadding A legacy property that adds additional padding based on font metrics at the top of the first line of text and the bottom of the last line. Setting this setting to false makes the default text layout more consistent with common design tools, making it easier to match generated design specifications. Upgrading to the January 2024 release may result in minor changes to text layout and screenshot testing. For more information about this setting, see Modify font padding in the Text Writing blog post and the developer documentation.
Support for non-linear font scaling
The January 2024 release uses non-linear font scaling to improve text readability and accessibility. Non-linear font scaling prevents large text elements on the screen from becoming too large by applying a non-linear scaling curve. This resizing strategy means that large text will not resize at the same rate as small text.
drag and drop
Compose Foundation adds support for platform-level drag and drop, which allows you to drag content between apps on devices running in multi-window mode. The API is 100% compatible with the View API. This means that a drag and drop initiated in a view can be dragged into Compose and vice versa. To use this API, see the code sample.
Additional features
Other features included in this release include:
- Eulji Jihada Preview range From the lazy list.
- Fixed an issue where composables that were disabled but kept active for reuse in lazy lists were not filtered out of the semantic tree by default.
- Spline-based keyframes for animation.
- Added support for mouse selection, including text.
start!
We appreciate all bug reports and feature requests submitted to our issue tracker. These requests help us improve Compose and build the APIs you need. Please continue to send us your feedback and help us improve Compose.
Wondering what’s next? Check out our roadmap to see what features we’re currently considering and working on. We can’t wait to see what you build next!
Have fun composing!