diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a567f..321c4b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,39 @@ version in `versions.properties`; versions before 0.28.0 are described in the gi log (one commit per version). Since 0.37.0 Android and iOS share one version and one feature set; the iOS side of each version is in `ios/CHANGELOG.md`. +## 0.41.2 (versionCode 78) + +Housekeeping and speed; nothing you can see changes, except that the app is +half the size and lighter on the battery. + +- **The APK is half as big** — 21.5 MB → 10.1 MB. Release builds now go through + R8 (shrink, optimise, obfuscate, and drop unused resources), which throws away + the Compose and Material icon code the app never calls. Only the two JNI + classes are pinned by name (`app/proguard-rules.pro`), because the native + library looks them up at runtime; `make dist` keeps the de-obfuscation map next + to the APK so a crash report from a published build can still be read. +- **Less battery while a song is stopped.** The thread that feeds the transport + display polled the engine 100 times a second whatever was happening; it now + does that only while the song plays or a recording is armed, and waits 100 ms a + turn otherwise. Pressing Play still moves the playhead in the same frame — a + transport call wakes it. iOS does the same (30 Hz playing, 10 Hz stopped). +- **Smoother editing.** Every edit hands the engine the whole song as text. That + text is now built in one pre-sized pass instead of a string per line, and a + burst of edits — dragging a note column, sweeping a knob — is collected into + one sync instead of one per touch event. +- **The mixer costs less per sample.** Channel volume, mute/solo and the effect + chain are read once per audio block rather than once per frame, in the shared + C++ engine (so iOS gets it too). Bit-for-bit the same audio: all 61 reference + scenarios still match the Kotlin DSP. +- **Dead code gone.** The Kotlin DSP that `core/` replaced in 0.37.0 was still + compiled into every APK although nothing called it; it has moved to the test + source set, where it belongs as the reference the C++ is checked against. The + golden tests' `TestVoice` wrappers left the shared engine's sources for the + same reason, and a handful of unused declarations are gone. +- Fix: `make lint` failed on a manifest that asked for `ACCESS_FINE_LOCATION` + without `ACCESS_COARSE_LOCATION` (the BLE MIDI scan on Android 8–11). Both are + declared and both are requested now, so `make check` passes again. + ## 0.41.1 (versionCode 77) - No Android change: an iOS redraw fix (see `ios/CHANGELOG.md`). diff --git a/Makefile b/Makefile index a08811a..6dca25f 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,10 @@ FDROID_METADATA := /var/lib/fdroid/metadata # directory expects; app/build.gradle.kts stamps the same name onto the output. APK_NAME := $(APP_ID)_$(VERSION_CODE).apk RELEASE_APK := app/build/outputs/apk/release/$(APK_NAME) +# R8 renames the release build, so a crash report from it is unreadable without +# this. It is staged beside the APK and kept locally — never published. +RELEASE_MAP := app/build/outputs/mapping/release/mapping.txt +DIST_MAP := dist/$(APP_ID)_$(VERSION_CODE)-mapping.txt STAGING_APK := app/build/outputs/apk/staging/app-staging.apk METADATA_YML := dist/$(APP_ID).yml @@ -110,12 +114,18 @@ launch: # ------------------------------------------------------------------ dist # Everything a publish needs, staged locally first so it can be inspected # before anything leaves the machine. -dist: dist/$(APK_NAME) $(METADATA_YML) +dist: dist/$(APK_NAME) $(DIST_MAP) $(METADATA_YML) dist/$(APK_NAME): $(RELEASE_APK) @mkdir -p dist cp $(RELEASE_APK) $@ +# The de-obfuscation map for this exact versionCode. `publish` does not upload it; +# it stays here so a stack trace from the published APK can still be read. +$(DIST_MAP): $(RELEASE_APK) + @mkdir -p dist + cp $(RELEASE_MAP) $@ + # F-Droid metadata. Regenerated from versions.properties on every dist so the # CurrentVersion lines can never lag the APK next to them. $(METADATA_YML): $(VERSIONS) Makefile @@ -153,6 +163,7 @@ publish-metadata: $(METADATA_YML) publish: publish-apk publish-metadata @echo "published $(APP_ID) $(VERSION_NAME) ($(VERSION_CODE)); sign it on the repo host" + @echo "keep $(DIST_MAP) — it is the only way to read a crash from this build" # ------------------------------------------------------------------ versioning # versionCode always moves by exactly 1: F-Droid and the package manager order diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1220f97..0f61a45 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -52,9 +52,13 @@ android { buildTypes { release { - // Shrinking is off by default so newcomers get readable stack traces. - // Flip to true once the app stabilises. - isMinifyEnabled = false + // R8: shrink + optimise + obfuscate, and drop unreferenced resources. + // Only the JNI entry points need keeping (see proguard-rules.pro); the + // app reflects over nothing of its own. A release stack trace is now + // obfuscated, so keep app/build/outputs/mapping/release/mapping.txt + // beside any APK you publish — `make dist` copies it into dist/. + isMinifyEnabled = true + isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", @@ -66,8 +70,9 @@ android { // the app un-optimised and makes Compose several times slower — so measuring // UI "snappiness" on a debug build is misleading. This variant flips // debuggability off (the single biggest perf lever) while reusing the debug - // signing key, so it still installs without a release keystore. R8/shrinking - // stays off to avoid needing JNI/Compose keep-rules for now. + // signing key, so it still installs without a release keystore. R8 stays off + // here on purpose: staging exists to measure the UI, and un-obfuscated stack + // traces are worth more than the last few hundred KB. `release` is minified. create("staging") { initWith(getByName("debug")) isDebuggable = false diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index fa9d3bb..0c47f94 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,3 +1,19 @@ -# ProGuard/R8 rules for release builds. Minification is currently disabled in -# build.gradle.kts (isMinifyEnabled = false), so this file is intentionally empty. -# Add keep-rules here if/when you enable shrinking and hit reflection issues. +# R8 rules for the release build (isMinifyEnabled = true in build.gradle.kts). +# +# Keep as little as possible: everything else — Compose, media3, DataStore, +# coroutines — ships its own consumer rules inside its AAR, and the app itself +# uses no reflection over its own classes (songs, presets, themes and bindings +# are all read and written as text by hand-written parsers in io/). + +# JNI. The native library resolves Java___ by +# name at *runtime*, so a renamed class or method is an UnsatisfiedLinkError on +# first play — not a build error. Both halves of the bridge must keep their +# names: audio/NativeEngine (the engine, src/main/cpp/jni_engine.cpp) and +# audio/NativeAudioBridge (the Oboe stream, src/main/cpp/native_audio.cpp). +-keepclasseswithmembernames,includedescriptorclasses class * { + native ; +} + +# Kotlin tells R8 what is nullable through these; dropping them makes R8's +# warnings about the Kotlin stdlib noisy for no gain. +-dontwarn kotlin.Unit diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a80539b..e853370 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,11 @@ BLUETOOTH_CONNECT : Bluetooth MIDI + gamepad on Android 12+. BLUETOOTH_SCAN : finding BLE MIDI controllers (Settings › MIDI inputs) on Android 12+; never used to derive location. - BLUETOOTH / _ADMIN / ACCESS_FINE_LOCATION : the same scan on Android 8-11. --> + BLUETOOTH / _ADMIN : the same scan on Android 8-11. + ACCESS_FINE_LOCATION + ACCESS_COARSE_LOCATION : a BLE scan on Android 8-11 + was gated on location permission. Both are declared + because the platform (and lint) treat FINE as an + upgrade of COARSE, and we only ever scan with them. --> @@ -20,6 +24,7 @@ android:usesPermissionFlags="neverForLocation" /> +