View profile

jetc.dev Newsletter - Issue #134

jetc.dev Newsletter - Issue #134
By Mark Murphy, CommonsWare • Issue #134 • View online
We got a new beta for Compose 1.3.0, and stuff keeps changing!
In addition, we look at animations and dual-pane UIs, plus steppers and lock patterns. However, a growing concern is performance, so we look at upcoming Flamingo composition tracing, and I worry about how weird our composables are going to get as we deal with this and other limitations.

Ooooo… What Did We Get?
Reviewing the release notes for the latest Jetpack Compose update!
Compose is out with a 1.3.0-beta03 release!
The big thing is that the lambdas that you pass to remember() and rememberCoroutineScope() are now considered to be crossinline. You cannot perform an early return from a crossinline lambda expression. That was never supported anyway, apparently, but now you get a clearer compiler error.
In addition, we got more stuff that seems like it should not be in a beta, such as:
  • Line-breaking options for Text()
  • A new withConsumedWindowInsets() modifier
  • An experimental pullRefresh() modifier for the popular pull-to-refresh pattern
(these are all great, but they feel more like changes that belong in an alpha, not a beta)
Wear Compose has a new 1.1.0-alpha06 release. In addition to fixing a PositionIndicator bug, they added a scrollAway() modifier for Column(), LazyColumn(), and ScalingLazyColumn(). The primary use case is to allow you to have the TimeText scroll with the content.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
How Do We Control Text Overflow?
Composable Commentary
Posts, videos, and other new information related to Jetpack Compose!
Medium: Jetpack Compose Composition Tracing
Medium: Composable Functions
Video: Taking Jetpack Compose animations to the next level
Jetpack Compose Accompanist TwoPane
Medium: Jetpack Compose Navigation Animation
Compose UI for iOS
How to remember the scroll position of LazyColumn built with Paging 3
Resource Roundup
100% pure code!
…And One More Thing
Compose is starting to show some cracks in its foundation.
The idea behind Compose was supposed to be simplicity: you “simply” declare what you want the UI to be based on the present state. Compose would arrange to:
  • Detect relevant state changes
  • Call your code to re-declare what the UI should be now
  • Figure out what changed between the previous UI and the new UI and make the necessary on-screen adjustments
You would just write nearly-ordinary functions to implement the code behind that second bullet. Using reactive data sources would “just work”, and Compose would be efficient when doing all of this.
And, at a high level, that is all still true. But, we are starting to see where the simplicity is not holding up:
  • Over-composing — doing unnecessary recompositions due to state changes — is a significant problem, dragging down performance. The good news is that the tooling is getting better for this, particularly in the Electric Eel and Flamingo editions of Android Studio. The bad news is that we have to start introducing artificial workarounds, like converting parameters into lambdas to reduce composition counts, as seen here and here.
  • Part of the theory behind composables, particularly the stock widgets, is that they are stateless. That is not always possible in practice. Last week’s warnings about TextField() stem from state management inside of TextField(), necessary because it needs to interact with external-to-Compose elements, such as the soft keyboard. As a result of this hidden state, we have to take steps to ensure that our composables are not wrecking that internal TextField() state management.
Neither of these things are show-stoppers. However, they do throw sand in the gears of Compose development. Worse, for teams who are currently considering whether or not to make the move to Compose, these sorts of problems cause more 🤔 or 🙃 than 😀.
In other words, some may feel that they are headed towards the trough of disillusionment.
If many more of these sorts of problems show up in the short term, Compose may be in for a rough go of it for a while. In the long run, it seems likely that Compose can be augmented to handle these two problems more naturally.
And, in the meantime… be sure to check your composition counts.
Did you enjoy this issue?
Mark Murphy, CommonsWare

Jetpack Compose news and notes.

In order to unsubscribe, click here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Powered by Revue