Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Compile the interface before it is first drawn

Leloniob249624accae
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 56d64a0..328215b 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -162,6 +162,9 @@ android {
dependencies {
implementation(libs.androidx.core.ktx)
+ // Installs baseline-prof.txt on first run, so the code the bar and the
+ // player use is compiled before it is needed rather than while it runs.
+ implementation(libs.androidx.profileinstaller)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.browser)
implementation(libs.androidx.security.crypto)
diff --git a/app/src/main/baseline-prof.txt b/app/src/main/baseline-prof.txt
new file mode 100644
index 0000000..6dac8d9
--- /dev/null
+++ b/app/src/main/baseline-prof.txt
@@ -0,0 +1,20 @@
+# What to compile ahead of time, so the first fold of the bar is as smooth as
+# the tenth.
+#
+# The bar was stuttering the first time it moved and settling after that, which
+# is not the animation: it is the code being compiled while it runs. Forcing the
+# whole app to compile ahead of time on the phone took the same cold gesture
+# from 43% dropped frames and 85ms at the 90th percentile to 28% and 57 — the
+# same numbers a warm run gives. These rules ship that head start.
+#
+# Coarse on purpose. A generated profile would name individual methods, and it
+# would be out of date the next time the UI changes; the drawing and animation
+# packages are small enough that compiling them whole costs little and keeps
+# being right.
+# The whole interface, not a chosen part of it. The first version named the
+# glass, the player and the shared components, and left out the screens: home,
+# library and search are where the scrolling happens, so the one gesture the
+# profile exists for was running interpreted anyway.
+HSPLdev/lelonio/square/ui/**->**(**)**
+HSPLdev/lelonio/square/playback/**->**(**)**
+HSPLdev/lelonio/square/data/**->**(**)**
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 1593e80..84a10d1 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -11,6 +11,7 @@ serialization = "1.7.3"
ktor = "3.5.2"
[libraries]
+androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version = "1.4.1" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.15.0" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.9.3" }
androidx-browser = { module = "androidx.browser:browser", version = "1.8.0" }