Skip to content

ADFA-2523 build: prevent TFLite model compression in release builds#820

Merged
hal-eisen-adfa merged 3 commits intostagefrom
fix/ADFA-2523
Jan 13, 2026
Merged

ADFA-2523 build: prevent TFLite model compression in release builds#820
hal-eisen-adfa merged 3 commits intostagefrom
fix/ADFA-2523

Conversation

@avestaadfa
Copy link
Contributor

Ensure .tflite files are stored raw to allow memory mapping by the interpreter.

Ensure .tflite files are stored raw to allow memory mapping by the interpreter.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Release Notes

Changes

  • Added "tflite" file extension to the androidResources.noCompress configuration to ensure TensorFlow Lite model files are not compressed during APK packaging
  • Extended the global noCompress set to include ML model file extensions: "tflite", "binarypb", "bincfg", "conv_model", and "lstm_model"
  • Added build dependency for CV module asset merging (mergeReleaseAssets) to ensure proper ordering before recompression in V8 release builds
  • Added build metadata file for v8 debug APK variant

Context

This change addresses an issue where MLKit and TFLite model files were either missing from release APKs or failing to initialize due to compression during the build process. The TensorFlow Lite interpreter requires memory-mapped access to model files, which is not possible with compressed assets.

Risks & Best Practices Concerns

  • APK Size Impact: Preventing compression of multiple model file formats will increase the final APK size. Verify that the increase is acceptable for your distribution targets.
  • Build Dependency Chain: The new build dependency on :cv-image-to-xml:mergeReleaseAssets introduces an explicit ordering constraint that could impact parallel build performance. Monitor build times to ensure no significant regression.
  • Model File Coverage: The addition of five model file extensions suggests this is a comprehensive fix for multiple ML frameworks. Ensure all necessary model formats are covered and no unintended file types are being excluded from compression.
  • Inconsistent Resource Handling: The change includes both androidResources.noCompress (single entry) and a separate global noCompress set (multiple entries). Clarify whether both mechanisms are necessary and if they serve different purposes to avoid maintenance confusion.

Walkthrough

Adds multiple file extensions (including tflite, binarypb, bincfg, conv_model, lstm_model) to the APK no-compression list and makes assembleV8Release depend on :cv-image-to-xml:mergeReleaseAssets. Also adds app/v8/debug/output-metadata.json describing the v8 debug APK artifact.

Changes

Cohort / File(s) Summary
Android build configuration
app/build.gradle.kts
Extended the noCompress set to include tflite, binarypb, bincfg, conv_model, lstm_model; added tflite to androidResources.noCompress; added assembleV8Release dependency on :cv-image-to-xml:mergeReleaseAssets.
Build artifact metadata
app/v8/debug/output-metadata.json
Added output metadata JSON for the v8 debug APK (version, artifactType, applicationId, variantName, element with versionCode/versionName/outputFile, and minSdkVersionForDexing).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • hal-eisen-adfa
  • jomen-adfa

Poem

🐰 A hop, a patch, models spared the squeeze,
No compression now — they rest with ease.
Assets merged in tidy rows,
Debug APK metadata shows.
Hooray — the rabbit happily knows! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: preventing TFLite model compression in release builds, which aligns with the changeset's core objective of modifying compression settings in build.gradle.kts.
Description check ✅ Passed The description is directly related to the changeset, explaining the technical rationale (memory mapping) for why .tflite files must not be compressed, which matches the build configuration changes made.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af56400 and 903b166.

📒 Files selected for processing (2)
  • app/build.gradle.kts
  • app/v8/debug/output-metadata.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/build.gradle.kts
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build Universal APK
🔇 Additional comments (1)
app/v8/debug/output-metadata.json (1)

1-21: This review comment is incorrect. output-metadata.json is not an auto-generated build artifact that was accidentally committed to version control.

Why the file belongs in the repository:

  • It is intentionally tracked in git and has commit history dating to when TFLite/MLKit compression issues were addressed
  • It resides in app/v8/debug/ (a source directory), not in build/outputs/ where Android Gradle Plugin auto-generates artifacts
  • It is not ignored in .gitignore, indicating deliberate inclusion
  • The app/v8/ directory contains flavor-specific metadata aligned with the build configuration for the v8 architecture variant (referenced in build.gradle.kts)

Relationship to PR objective:
The file is directly related to the stated PR objective of preventing TFLite model compression in release builds—it was added as part of addressing compression-related issues with MLKit and TFLite models.

Likely an incorrect or invalid review comment.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hal-eisen-adfa hal-eisen-adfa changed the title build: prevent TFLite model compression in release builds ADFA-2523 build: prevent TFLite model compression in release builds Jan 12, 2026
…sing

from the release APK or failing to initialize due to compression.
@hal-eisen-adfa hal-eisen-adfa merged commit 5fdba6b into stage Jan 13, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the fix/ADFA-2523 branch January 13, 2026 17:17
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.

4 participants