Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unusable or Undebuggable? Rebelling against "best practices"

Louis CAD
April 27, 2023

Unusable or Undebuggable? Rebelling against "best practices"

Thanks to new Compose libraries, making a good looking Wear OS app is becoming very easy!

However, on the watch, if you need to scroll, LazyColumn gives you 5-10 frames per second at best in debug mode.

Unusable? Unacceptable!

Actually, I noticed the scrolling performance wasn't that great in debug on the phone too, so I went on to fix this, succeeded, and got bonus features I missed in LazyColumn!

You'll learn the full story and see how it's all implemented.

Louis CAD

April 27, 2023
Tweet

More Decks by Louis CAD

Other Decks in Programming

Transcript

  1. Who is your speaker His name is: Louis CAD •

    Developed for Android since 2014 • Wears smartwatches since 2015 (Android Wear / Wear OS) • Kotlin lover since 2016 • Does open source since 2016 with Splitties, and other projects • Currently focused on Charts-kt by Data2Viz, a commercial Kotlin Multiplatform charting library (JS, iOS, JVM, & Android of course) • Also doing Wear OS apps, and contributing to OSS projects
  2. @Louis_CAD Reproduced on 3 watches (Samsung, Mobvoi, Google) Unreproducible on

    the emulator… Component: ScalingLazyColumn .com/android/wear-os-samples/issues/238 Jank and poor scrolling performance on the ComposeAdvanced sample
  3. @Louis_CAD Reported in 2022 (12th March) Reproduced on 3 watches

    (Samsung, Mobvoi, Google) Unreproducible on the emulator… Component: ScalingLazyColumn .com/android/wear-os-samples/issues/238 Jank and poor scrolling performance on the ComposeAdvanced sample
  4. @Louis_CAD Reported in 2022 (12th March) Reproduced on 3 watches

    (Samsung, Mobvoi, Google) Unreproducible on the emulator… Component: ScalingLazyColumn "Closed as completed" within 4 days! 🎉⁉ .com/android/wear-os-samples/issues/238 Jank and poor scrolling performance on the ComposeAdvanced sample
  5. @Louis_CAD Reported in 2022 (12th March) Reproduced on 3 watches

    (Samsung, Mobvoi, Google) Unreproducible on the emulator… Component: ScalingLazyColumn "Closed as completed" within 4 days! 🎉⁉ .com/android/wear-os-samples/issues/238 Jank and poor scrolling performance on the ComposeAdvanced sample
  6. Conclusion • Don't debug your app on an actual watch?

    • Enjoy the ergonomics of manipulating a watch emulator with a mouse pointer! • release build: really slower than debug build? (yes)
  7. In the mind of a rebel about to hack around

    Back in 2015 (7-8 years ago), scrolling was smooth on my LG G Watch It doesn't have to be! 
 People need to know. People say RecyclerView is verbose I don't remember RecyclerView being laggy LazyColumn lagging behind RecyclerView? 
 Déjà vu Insertions and removals animations? I wrapped RecyclerView to get them Let's try that thing again?
  8. @Louis_CAD LazyColumn RecyclerView Simple, high-level API, out of the box

    👌 Ok-ish/poor performance in debug mode 😕 @Louis_CAD No insertion/removal animations 😭 Lower-level API, complex by default 🫤 As smooth as its content 🤞 Animates all item changes, by default 😎 Scrolling friction on Samsung GW4 😓 Keeps all user input ✅
  9. What if LazyColumn was using RecyclerView under the hood? I

    heard SwiftUI kinda does that on iOS: Using UITableView for LazyVStack & LazyHStack.
  10. @Louis_CAD LazyColumn RecyclerView Simple, high-level API, out of the box

    👌 Ok-ish/poor performance in debug mode 😕 @Louis_CAD No insertion/removal animations 😭 Lower-level API, complex by default 🫤 As smooth as its content 🤞 Animates all item changes, by default 😎 Scrolling friction on Samsung GW4 😓 Keeps all user input ✅
  11. @Louis_CAD LazyColumnWithRecyclerView Simple, high-level API, out of the box 👌

    Ok-ish/poor performance in debug mode 😕 @Louis_CAD No insertion/removal animations 😭 Lower-level API, complex by default 🫤 As smooth as its content* 🤞 Animates all item changes, by default 😎 Scrolling friction on Samsung GW4 😓 Keeps all user input ✅
  12. @Louis_CAD LazyColumnWithRecyclerView Simple, high-level API, out of the box 👌

    @Louis_CAD As smooth as its content* 🤞 Animates all item changes, by default 😎 Keeps all user input ✅ Let's look at that, top to bottom.
  13. @Louis_CAD LazyColumnWithRecyclerView Simple, high-level API, out of the box 👌

    @Louis_CAD As smooth as its content* 🤞 Animates all item changes, by default 😎 Keeps all user input ✅ *Some of the lag is caused by missing pro fi le for Composable content… 
 …so we only made the issue less bad… 😶 
 Scrolling the app a bit gets JIT to fi x the issue, until next deploy. 
 Better than nothing!