Skip to content

Lite APK を約58 MBへ縮小 / Reduce Lite APKs to about 58 MB - #1330

Merged
KazumaProject merged 3 commits into
devfrom
codex/fdroid-lite-release
Nov 15, 2026
Merged

KazumaProject merged 3 commits into
devfrom
codex/fdroid-lite-release

Conversation

@KazumaProject

@KazumaProject KazumaProject commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

日本語

Lite APK の大部分を占める辞書・索引を XZ 圧縮して同梱し、APK を約58 MBに縮小します。辞書内容とメモリマップによる検索を維持し、初回利用時に端末内へ展開します。

  • org.tukaani:xz:1.12 をビルド側・実行側に固定し、6個の辞書・索引を圧縮します。展開サイズとSHA-256を含む決定的なマニフェストを生成します。
  • 使用する資源だけをアプリ専用・バックアップ対象外の領域へ展開し、サイズとSHA-256を照合して読み取り専用ファイルをアトミックに公開します。スレッド・プロセス間でロックし、変更された資源の旧コピーを削除します。再利用時はハッシュ名とサイズを確認します。
  • キャッシュ書き込みに失敗した場合はメモリ上で展開・照合して読み込みます。この経路は通常よりヒープを使います。
  • 先行変更の英語文字表の縮小、旧辞書の重複除去、ストリーム用接続行列の圧縮も含みます。
  • XZのライセンス原文・依存一覧を追加します。対象PRでも独立したF-Droidクリーンビルド2回とバイト一致検証を実行します。

同じ dev 0fc6a8634 を起点とする署名なしのローカル release ビルドで比較しました(MB = 1,000,000 bytes)。

APK 修正前 修正後
Lite Standard 106,373,583 bytes 58,279,475 bytes
Lite F-Droid 117,417,153 bytes 58,279,463 bytes

検証済み:両Liteリリースビルド、デコーダー・展開キャッシュの単体テスト12件、既存辞書差し替えテスト63件、リリースツールのテスト19件、全6資源の展開後バイト一致、APK配置・ハッシュ検査、実際のRelease依存解決結果とライセンスカタログの照合、actionlint。

全6資源を展開すると別途65.73 MBを使用します。APKとこの展開物の合計は約124.01 MBで、その他のアプリデータ・OSの最適化領域は含みません。APKダウンロード量の削減であり、端末内の総使用量も同じだけ減る変更ではありません。

Android 17 / arm64 エミュレータ(4 GiB、2コア)の分離パッケージで検証しました。release variant、R8有効、debug署名、テストから呼ぶAPIを保持する追加ProGuardルールという条件です。各回アプリのプロセスを再起動し、初回条件では展開物を削除しました。

条件 6資源と接続表の読み込み時間 結果
圧縮版・展開なし(3回) 2.61〜2.95秒 全配列・英単語候補・日本語辞書読み込み・文法データ・接続コスト照合に成功
圧縮版・展開済み(3回) 68.9〜94.0 ms 同じ照合に成功、キャッシュ再利用
キャッシュ書込不可を模擬(1回) 2.44秒 メモリ上の展開経路でも同じ照合に成功

書込不可はキャッシュ用パスを通常ファイルにして模擬しました。その条件の計測後PSSは94,505 KiB、展開済み条件では78,972〜79,014 KiBでした。OSページキャッシュやホスト負荷は制御しておらず、エミュレータの参考値です。全画面の起動時間・候補表示遅延を測るベンチマークではありません。物理Pixel 6は接続が切れたため、この更新での実機性能は未確認です。

更新後のLinux CIも成功しました。独立したクリーンビルド2回、ソースリビジョン照合、全XZ資源の展開・ハッシュ検査、単体テスト、APKバイト一致確認を通過しています。CI APKの6資源も旧PR CIの非圧縮データと全バイト一致しました。

全画面のUI操作、Full版のネイティブビルド、公式fdroidserver環境での再ビルドは未検証です。公式F-Droidへの配布は別途更新が必要です。新しいバージョン・タグでリリースし、既存タグや公開APKを置き換えないでください。

APK・ログ・端末検証コードはすべてリポジトリ外に保存しています。

English

Compress the six large bundled dictionaries/indexes with XZ to reduce Lite APKs to approximately 58 MB. Retain dictionary contents and memory-mapped lookup by expanding assets into private storage on first use.

  • Pin the build-time encoder and runtime decoder to org.tukaani:xz:1.12; emit deterministic uncompressed sizes and SHA-256 hashes.
  • Verify and atomically publish read-only, content-addressed copies under no-backup storage. Synchronize threads/processes, remove obsolete copies, and check the hash-based filename and size on reuse.
  • If cache writes fail, decode and verify in memory, with a higher heap cost.
  • Include the preceding label-alphabet packing, legacy dictionary deduplication and streamed connection-matrix compression.
  • Include the XZ license and resolved dependency catalog. Run independent clean F-Droid builds and byte comparison on relevant PRs.

The table above compares unsigned local release builds from dev 0fc6a8634 with identical SDK/JDK settings. Both Lite APKs now build at approximately 58.28 MB.

Passed: both release builds, 12 decoder/cache unit tests, 63 existing override tests, 19 release-tool tests, byte-for-byte parity of all six expanded assets, APK format/hash checks, actual release dependency/catalog validation and actionlint.

Expanding all six assets uses an additional 65.73 MB of private storage. The APK plus those copies total approximately 124.01 MB, excluding other app data and OS optimization files. This is a download-size reduction; total installed storage does not decrease by the same amount.

Validated on an isolated Android 17 arm64 emulator (4 GiB, two cores), using the release variant with R8, debug signing and additional rules retaining APIs called by instrumentation. Each run starts a new application process; the first-use condition also deletes expanded copies.

  • First use, three runs: 2.61–2.95 seconds to load six assets and the connection matrix.
  • Cached, three runs: 68.9–94.0 ms.
  • Unwritable-cache simulation, one run: 2.44 seconds; the verified in-memory path also passes.

Every run verifies original English arrays, English word lookup, Japanese dictionary loading, grammar availability and sampled connection costs. The unwritable condition uses a regular file at the cache-directory path. Post-load PSS is 94,505 KiB in that fallback and 78,972–79,014 KiB in cached runs. OS page cache and host load were not controlled. These are emulator observations, not full UI or candidate-display latency measurements. The physical Pixel 6 disconnected; hardware performance for this update remains unverified.

The updated Linux CI passes two independent clean builds, source-revision checks, XZ/hash validation, unit tests and byte-for-byte APK comparison. All six expanded CI assets also match the previous PR CI's uncompressed bytes.

Full UI coverage, Full native builds and the official fdroidserver environment remain unverified. Official F-Droid distribution requires a separate update. Publish with a new version/tag rather than replacing existing assets.

APKs, logs and temporary probes stay outside the repository.

@KazumaProject KazumaProject changed the title Lite APK を軽量化し F-Droid 検証を強化 / Reduce Lite size and verify F-Droid builds Lite APK を約58 MBへ縮小 / Reduce Lite APKs to about 58 MB Nov 14, 2026
@KazumaProject
KazumaProject merged commit f1e6032 into dev Nov 15, 2026
4 checks passed
@KazumaProject
KazumaProject deleted the codex/fdroid-lite-release branch November 15, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant