From ba98ec56f493459d0ad5125db52aef82cda4d208 Mon Sep 17 00:00:00 2001 From: Reactorcoremeltdown Date: Wed, 18 Nov 2026 10:21:09 +0100 Subject: [PATCH] 0.41.2 (78): cleanup and optimisation round (Android and iOS) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing user-visible changes, except that the Android app is half the size and both are lighter on the battery. R8 is on for release builds (21.5 MB -> 10.1 MB); only the two JNI classes are pinned by name, since the app reflects over nothing of its own, and `make dist` keeps the mapping beside the APK. The Kotlin DSP that core/ replaced in 0.37.0 was still compiled into every APK with nothing calling it — it moves to the test source set, where it belongs as the reference the C++ is checked against — and the golden tests' TestVoice wrappers leave core/src for core/tests/voices, so neither app compiles them either. Speed: channel gain, mute/solo and the FX chain are read once per audio block instead of once per frame in Engine::fillBlock (both platforms, bit-identical — all 61 reference scenarios still match); the transport pollers idle at 100 ms (Android) and 10 Hz (iOS) instead of polling flat out while a song is stopped, woken by any transport call; ProjectIo.save builds into one pre-sized buffer and a burst of edits is coalesced into one engine sync; the Kotlin grain sources and factory wavetables are built when their editor opens rather than at launch, where they duplicated ~6 MB the engine already renders in core/; and Xcode builds the DSP core at -O2, the level the golden tests measure, not -Os. Fix: `make lint` failed on a manifest asking for ACCESS_FINE_LOCATION without ACCESS_COARSE_LOCATION (the BLE MIDI scan on Android 8-11), so `make check` passes again. Co-Authored-By: Claude Opus 5 --- CHANGELOG.md | 33 ++++ Makefile | 13 +- app/build.gradle.kts | 15 +- app/proguard-rules.pro | 22 ++- app/src/main/AndroidManifest.xml | 7 +- .../tiredsysadmin/android/sizzle/SizzleApp.kt | 10 +- .../android/sizzle/audio/AudioEngine.kt | 46 ++++-- .../android/sizzle/input/BleMidi.kt | 4 +- .../android/sizzle/input/MidiClock.kt | 14 +- .../android/sizzle/io/ProjectIo.kt | 99 ++++++++---- .../android/sizzle/model/Toolbox.kt | 16 +- .../android/sizzle/ui/AppViewModel.kt | 3 - .../sizzle/ui/settings/SettingsScreen.kt | 4 +- .../sizzle/ui/toolbox/GrainCloudEditor.kt | 7 + .../sizzle/ui/toolbox/TapeEngineEditor.kt | 2 +- .../sizzle/ui/toolbox/WavetableEditor.kt | 7 + .../android/sizzle/audio/AmbienceReverb.kt | 6 + .../android/sizzle/audio/Effects.kt | 6 + .../android/sizzle/audio/MasterRecorder.kt | 6 + .../android/sizzle/audio/SampleVoice.kt | 6 + .../android/sizzle/audio/SynthPatch.kt | 6 + .../android/sizzle/audio/SynthVoice.kt | 7 +- .../android/sizzle/echofield/GrainCloud.kt | 6 + .../android/sizzle/frasil/FrasilPatch.kt | 6 + .../android/sizzle/frasil/FrasilVoice.kt | 6 + .../android/sizzle/wavetable/WaveVoice.kt | 6 + core/src/engine/ChannelArp.hpp | 1 - core/src/engine/Engine.cpp | 27 +++- core/src/frasil/FrasilVoice.hpp | 2 - core/tests/golden_test.cpp | 2 +- .../voices}/FrasilTestVoice.cpp | 2 +- .../voices}/GrainTestVoice.cpp | 6 +- .../voices}/SampleTestVoice.cpp | 6 +- .../synth => tests/voices}/SynthTestVoice.cpp | 2 +- .../sizzle => tests/voices}/TestVoice.hpp | 0 core/{src => tests/voices}/TestVoices.cpp | 2 +- .../voices}/WaveTestVoice.cpp | 6 +- docs/DEVELOPER_HANDOVER.md | 147 +++++++++++------- ios/CHANGELOG.md | 22 +++ ios/Makefile | 8 +- ios/README.md | 17 +- ios/app/Host/AppModel.swift | 46 +++++- ios/app/Host/PluginCheck.swift | 5 - .../Host/Screens/Setup/SetupComponents.swift | 25 --- ios/app/project.yml | 7 +- versions.properties | 4 +- 46 files changed, 508 insertions(+), 192 deletions(-) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/audio/AmbienceReverb.kt (98%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/audio/Effects.kt (98%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/audio/MasterRecorder.kt (93%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/audio/SampleVoice.kt (96%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/audio/SynthPatch.kt (94%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/audio/SynthVoice.kt (97%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/echofield/GrainCloud.kt (98%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/frasil/FrasilPatch.kt (86%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/frasil/FrasilVoice.kt (98%) rename app/src/{main => test}/java/cc/tiredsysadmin/android/sizzle/wavetable/WaveVoice.kt (97%) rename core/{src/frasil => tests/voices}/FrasilTestVoice.cpp (98%) rename core/{src/echofield => tests/voices}/GrainTestVoice.cpp (93%) rename core/{src/sampler => tests/voices}/SampleTestVoice.cpp (94%) rename core/{src/synth => tests/voices}/SynthTestVoice.cpp (98%) rename core/{include/sizzle => tests/voices}/TestVoice.hpp (100%) rename core/{src => tests/voices}/TestVoices.cpp (97%) rename core/{src/wavetable => tests/voices}/WaveTestVoice.cpp (91%) 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" /> +