Skip to content

[Maintenance] Reduce code and mobile bundle size with measured budgets #206

Description

@0xSero

Goal

Reduce Litter's maintained code, release bundle size, build/runtime cost, and duplicated platform behavior without weakening iOS/Android parity or deleting code on textual-reference guesses.

This builds on merged PR #192, which removed dead Rust crates and folded the mobile bridge. The next phase must be measured and split into small, independently reversible PRs.

Current source/package baseline (2026-08-04 main)

  • 1,009 tracked files; roughly 79k Swift, 48k Kotlin, and 73k Rust lines before generated/submodule exclusions are refined.
  • 51 direct Android dependency declarations, 7 iOS package declarations, and 5 in-repository Rust manifests across the mobile/kittylitter build.
  • 53.5 MB of tracked content. The largest release inputs include two iOS animated home-cat PNGs (~10.5 MB total) and two Android animated WebPs (~8.7 MB total), plus duplicated cross-platform tip/transmission art.

These are repository measurements, not installed IPA/AAB proof. The first PR must establish authoritative packaged-artifact baselines.

Guardrails

  • Preserve behavior and all named mobile parity surfaces.
  • Shared session/thread/streaming/hydration/discovery/auth/voice policy stays in Rust; do not trade Rust deletion for duplicate Swift/Kotlin state machines.
  • Generated bindings, third-party submodules, debug-only harnesses, SwiftUI type inference, and package/release inputs require compiler/build evidence before deletion.
  • Report compressed and installed/uncompressed sizes separately. Source LOC is diagnostic, not a success metric by itself.
  • Each optimization PR must include before/after measurements, tests, and rollback scope.

Workstreams

1. Establish budgets and regression reporting

  • Record IPA/AAB/APK, per-ABI JNI, iOS staticlib/framework, asset, and dependency contribution sizes in CI.
  • Add warning/failure budgets with an explicit update process and a human-readable diff artifact.
  • Add cold launch, reconnect, thread hydration, first render, and realtime negotiation timing probes where not already covered by perf: instrument the mobile↔host paths so latency claims are measurable #189.

2. Remove package weight

  • Re-encode oversized animated assets with visual/alpha/frame-timing comparison and device rendering proof.
  • Ensure release packages exclude screenshots, debug harnesses, unused architectures, stale frameworks, symbols, and development-only resources.
  • Audit direct dependencies for unused or replaceable libraries; remove one dependency per focused PR with platform builds.
  • Use platform release optimizations deliberately: dead stripping and resource rules on iOS; R8/resource shrinking and ABI/app-bundle splits on Android, with startup/JNI tests.

3. Simplify maintained code

  • Find duplicated Swift/Kotlin normalization/reducer/cache logic and move only truly shared policy into the existing Rust crate.
  • Delete superseded compatibility paths only after current protocol/version usage is proven absent.
  • Reduce bridge surface area and generated bindings by moving direct operations to AppClient and keeping AppStore composite-only.
  • Split oversized files/modules by coherent responsibility when it reduces change coupling; do not churn files for line-count aesthetics.

4. Improve runtime/build efficiency

  • Profile before optimizing: hydration/reconnect, markdown/stream rendering, asset decode, database/index work, UniFFI crossings, and build hot spots.
  • Bound unbounded work and remove repeated parsing/projection only when traces show it matters.
  • Keep fast local lanes and CI cache behavior reproducible.

Acceptance criteria

  • CI publishes authoritative package/component size reports for iOS and Android and rejects unexplained regressions over agreed budgets.
  • Every cleanup PR includes before/after bytes and relevant behavior/build/device proof.
  • No user-facing parity regression; shared behavior remains one Rust implementation with thin platform projection.
  • Release IPA/AAB installed size and cold-start/reconnect timings improve from the recorded baseline, with targets set after measurement.
  • Deleted code/assets/dependencies have compiler, build graph, package inspection, and where relevant device evidence.
  • The final report lists net maintained LOC, dependency count, package size, launch/reconnect latency, and all intentionally retained complexity.

Initial PR sequence

  1. Size-report script + CI artifacts/budgets (measurement only).
  2. Animated home asset compression with frame/alpha/visual and device proof.
  3. Release-package content audit/removal.
  4. Dependency removals and shared-state simplifications, one behavior area per PR.

Keep this issue open only while it is an active measured program; close or split it once the budgets and remaining work are owned by narrower issues.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: nextImportant follow-up after critical correctness work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions