π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Consolidate ONNX Runtime package metadata
laurenspriem107ac3a6c9e8
diff --git a/mobile/apps/photos/android/app/build.gradle b/mobile/apps/photos/android/app/build.gradleindex 74828d180c..57cc8ec116 100644--- a/mobile/apps/photos/android/app/build.gradle+++ b/mobile/apps/photos/android/app/build.gradle@@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) {// Ente's custom prebuilt ONNX Runtime AAR is resolved straight from its// GitHub release through an Ivy repository; its SHA-256 is pinned in-// gradle/verification-metadata.xml. See mobile/native/onnxruntime/README.md.+// gradle/verification-metadata.xml. See mobile/native/onnxruntime.md.repositories {exclusiveContent {forRepository {diff --git a/mobile/apps/photos/android/gradle/verification-metadata.xml b/mobile/apps/photos/android/gradle/verification-metadata.xmlindex 34f8f0d32d..fbc6832b29 100644--- a/mobile/apps/photos/android/gradle/verification-metadata.xml+++ b/mobile/apps/photos/android/gradle/verification-metadata.xml@@ -7,7 +7,7 @@metadata), so their SHA-256 digests are pinned here. The digests come fromthe SHA256SUMS asset published with the ort-packaging release.- See mobile/native/onnxruntime/README.md for the release bump checklist.+ See mobile/native/onnxruntime.md for the release bump checklist.--><verification-metadata xmlns="https://schema.gradle.org/dependency-verification"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"diff --git a/mobile/apps/photos/ios/Podfile b/mobile/apps/photos/ios/Podfileindex 44c98ef96c..9650194d01 100644--- a/mobile/apps/photos/ios/Podfile+++ b/mobile/apps/photos/ios/Podfile@@ -36,7 +36,7 @@ target 'Runner' do# Ente's custom prebuilt ONNX Runtime static libraries (download + SHA-256# verification handled by CocoaPods). Consumed by the ente_photos_rust# build phase, which points the Rust `ort` crate at the platform slice.- pod 'EnteOnnxRuntime', :podspec => '../../../native/onnxruntime/EnteOnnxRuntime.podspec'+ pod 'EnteOnnxRuntime', :podspec => '../../../native/apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspec'flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lockindex 2a0c72a289..8619761181 100644--- a/mobile/apps/photos/ios/Podfile.lock+++ b/mobile/apps/photos/ios/Podfile.lock@@ -266,7 +266,7 @@ DEPENDENCIES:- ente_qr (from `.symlinks/plugins/ente_qr/ios`)- ente_rust (from `.symlinks/plugins/ente_rust/ios`)- ente_screen_cover (from `.symlinks/plugins/ente_screen_cover/ios`)- - EnteOnnxRuntime (from `../../../native/onnxruntime/EnteOnnxRuntime.podspec`)+ - EnteOnnxRuntime (from `../../../native/apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspec`)- ffmpeg_kit_flutter (from `.symlinks/plugins/ffmpeg_kit_flutter/ios`)- file_saver (from `.symlinks/plugins/file_saver/ios`)- firebase_core (from `.symlinks/plugins/firebase_core/ios`)@@ -366,7 +366,7 @@ EXTERNAL SOURCES:ente_screen_cover::path: ".symlinks/plugins/ente_screen_cover/ios"EnteOnnxRuntime:- :podspec: "../../../native/onnxruntime/EnteOnnxRuntime.podspec"+ :podspec: "../../../native/apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspec"ffmpeg_kit_flutter::path: ".symlinks/plugins/ffmpeg_kit_flutter/ios"file_saver:@@ -548,6 +548,6 @@ SPEC CHECKSUMS:wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556workmanager_apple: 904529ae31e97fc5be632cf628507652294a0778-PODFILE CHECKSUM: 7af4c0a38ff14aa9b6ef0b1309156a8d783a20c6+PODFILE CHECKSUM: c2a274bcfa5cc0e68e6b4387a846407ac479bae9COCOAPODS: 1.17.0diff --git a/mobile/native/android/apps/ensu/gradle/verification-metadata.xml b/mobile/native/android/apps/ensu/gradle/verification-metadata.xmlindex 34f8f0d32d..fbc6832b29 100644--- a/mobile/native/android/apps/ensu/gradle/verification-metadata.xml+++ b/mobile/native/android/apps/ensu/gradle/verification-metadata.xml@@ -7,7 +7,7 @@metadata), so their SHA-256 digests are pinned here. The digests come fromthe SHA256SUMS asset published with the ort-packaging release.- See mobile/native/onnxruntime/README.md for the release bump checklist.+ See mobile/native/onnxruntime.md for the release bump checklist.--><verification-metadata xmlns="https://schema.gradle.org/dependency-verification"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"diff --git a/mobile/native/android/apps/ensu/settings.gradle.kts b/mobile/native/android/apps/ensu/settings.gradle.ktsindex cabf7d6ad0..7bca1adbc0 100644--- a/mobile/native/android/apps/ensu/settings.gradle.kts+++ b/mobile/native/android/apps/ensu/settings.gradle.kts@@ -14,7 +14,7 @@ dependencyResolutionManagement {maven { url = uri("https://jitpack.io") }// Ente's custom prebuilt ONNX Runtime AAR is resolved straight from// its GitHub release; its SHA-256 is pinned in- // gradle/verification-metadata.xml. See mobile/native/onnxruntime/README.md.+ // gradle/verification-metadata.xml. See mobile/native/onnxruntime.md.exclusiveContent {forRepository {ivy {diff --git a/mobile/native/onnxruntime/EnteOnnxRuntime.podspec b/mobile/native/apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspecsimilarity index 95%rename from mobile/native/onnxruntime/EnteOnnxRuntime.podspecrename to mobile/native/apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspecindex a4904e47ed..88e9ba3cb5 100644--- a/mobile/native/onnxruntime/EnteOnnxRuntime.podspec+++ b/mobile/native/apple/packages/EnteOnnxRuntime/EnteOnnxRuntime.podspec@@ -4,7 +4,7 @@# the ente_photos_rust pod's build phase points the Rust `ort` crate at the# XCFramework's static archive for the active platform via ORT_LIB_PATH.#-# See README.md next to this file for the release bump checklist.+# See mobile/native/onnxruntime.md for the release bump checklist.Pod::Spec.new do |s|s.name = 'EnteOnnxRuntime's.version = '1.27.0-r3'diff --git a/mobile/native/apple/packages/EnteOnnxRuntime/Package.swift b/mobile/native/apple/packages/EnteOnnxRuntime/Package.swiftindex 63f9c42e3c..d83c90541d 100644--- a/mobile/native/apple/packages/EnteOnnxRuntime/Package.swift+++ b/mobile/native/apple/packages/EnteOnnxRuntime/Package.swift@@ -9,7 +9,7 @@// "disable-linking" so that it neither downloads nor bundles any other ONNX// Runtime; the symbols resolve against this static library at app link time.//-// See mobile/native/onnxruntime/README.md for the release bump checklist.+// See mobile/native/onnxruntime.md for the release bump checklist.import PackageDescriptionlet package = Package(diff --git a/mobile/native/onnxruntime.md b/mobile/native/onnxruntime.mdnew file mode 100644index 0000000000..736f281e94--- /dev/null+++ b/mobile/native/onnxruntime.md@@ -0,0 +1,44 @@+# Custom ONNX Runtime binaries++Photos and Ensu use Ente's pinned ONNX Runtime 1.27.0 packaging build,+`ort-1.27.0-r3` from the ort-packaging repository.++## Consumers++- Android resolves `io.ente.onnxruntime:onnxruntime-webgpu-android` directly+ from the GitHub release and verifies its SHA-256 with Gradle. The AAR contains+ WebGPU, XNNPACK, and CPU support for ARM64, ARMv7, and x86_64.+- Photos on iOS uses the `EnteOnnxRuntime` pod as a verified downloader. The+ pod is deliberately not a vendored framework; `ente_photos_rust` links the+ selected static XCFramework archive through `ORT_LIB_PATH`.+- Ensu on iOS links the same static XCFramework through SwiftPM. Its Rust+ `ort-sys` dependency uses `disable-linking` so ONNX Runtime is linked once by+ the app.++## Updating the release++Use the digests in the release's `SHA256SUMS` asset and keep every mobile+consumer on the same packaging revision.++- iOS: update `Package.swift` and `EnteOnnxRuntime.podspec` in+ `mobile/native/apple/packages/EnteOnnxRuntime`, then run `pod install` in+ `mobile/apps/photos/ios` and commit the updated lockfile.+- Photos Android: update `mobile/apps/photos/android/app/build.gradle` and its+ `gradle/verification-metadata.xml`.+- Ensu Android: update+ `mobile/native/android/apps/ensu/rust/build.gradle.kts` and its+ `gradle/verification-metadata.xml`.++## Building Photos Rust directly for iOS++Xcode normally sets `ORT_LIB_PATH`. For a direct Cargo invocation, install the+Photos pods first and set it explicitly:++```sh+ORT_LIB_PATH="$PWD/mobile/apps/photos/ios/Pods/EnteOnnxRuntime/onnxruntime.xcframework/ios-arm64" \+IPHONEOS_DEPLOYMENT_TARGET=15.1 \+cargo check -p ente-photos --target aarch64-apple-ios+```++For an Apple Silicon Simulator build, use the `ios-arm64-simulator` slice and+the `aarch64-apple-ios-sim` Rust target.diff --git a/mobile/native/onnxruntime/README.md b/mobile/native/onnxruntime/README.mddeleted file mode 100644index a8029a88fb..0000000000--- a/mobile/native/onnxruntime/README.md+++ /dev/null@@ -1,83 +0,0 @@-# Custom ONNX Runtime binaries--The mobile apps use Ente's pinned custom ONNX Runtime 1.27.0 packaging build-(`ort-1.27.0-r3` from the ort-packaging repository):--- Android: WebGPU, XNNPACK, and CPU; ARM64, ARMv7, and x86_64-- iOS: CoreML and CPU; iOS 15.1+ device and ARM64 Simulator--Each platform's own package manager downloads and checksum-verifies the-binaries; there are no custom download scripts.--- **Android**: the AAR is resolved as a regular Gradle dependency- (`io.ente.onnxruntime:onnxruntime-webgpu-android`) from an Ivy repository- that points directly at the GitHub release. Its SHA-256 is pinned via- Gradle dependency verification. Used by the photos app and ensu.-- **iOS (photos)**: the release ZIP is downloaded by CocoaPods as the local- `EnteOnnxRuntime` pod (`EnteOnnxRuntime.podspec` in this directory), which- pins its SHA-256. The `ente_photos_rust` pod's build phase exports- `ORT_LIB_PATH` pointing at the static archive inside the XCFramework's active- platform slice, which the Rust `ort` crate links statically. The podspec uses- `preserve_paths`, not `vendored_frameworks`, so CocoaPods does not also link- or embed the XCFramework.-- **iOS (ensu)**: the Ensu Xcode project links the static-library XCFramework from- the same ZIP through Swift Package Manager- (`mobile/native/apple/packages/EnteOnnxRuntime/Package.swift`, a binary- target with a pinned checksum). The Rust side builds `ort-sys` with- `disable-linking` on iOS (see `rust/crates/ensu/Cargo.toml`), so cargo- neither downloads nor bundles any other ONNX Runtime; symbols resolve- against the SPM static library at app link time. Note: because of this, build- `ente-ensu-uniffi` for iOS with `--crate-type staticlib` (as the app's- `build-rust.sh` does); the cdylib crate type cannot link on iOS since- nothing provides ONNX Runtime at cargo link time.--Desktop ONNX Runtime packaging is intentionally unchanged.--## Bumping the pinned release--Update the release tag, version, and SHA-256 digests (published as the-`SHA256SUMS` release asset) for the platform being bumped.--For iOS:--1. `EnteOnnxRuntime.podspec` (this directory): `s.version`, `:http` URL, and- `:sha256`; then run `pod install` in `mobile/apps/photos/ios`.-2. `mobile/native/apple/packages/EnteOnnxRuntime/Package.swift`: the binary- target URL and checksum (the checksum is the plain SHA-256 of the iOS- ZIP, identical to the one used in 1).--For Android:--1. `mobile/apps/photos/android/app/build.gradle`: the- `io.ente.onnxruntime:onnxruntime-webgpu-android` dependency version.-2. `mobile/apps/photos/android/gradle/verification-metadata.xml`: the- component version, artifact file name, and SHA-256.-3. `mobile/native/android/apps/ensu/rust/build.gradle.kts`: the dependency- version.-4. `mobile/native/android/apps/ensu/gradle/verification-metadata.xml`: the- same component, artifact, and SHA-256 updates as 2.--## WebGPU rollout status--On Android, the WebGPU execution provider is opt-in at runtime-(`set_ml_execution_config` in the Rust ML bindings; the photos app currently-enables it for internal users only) and is additionally restricted to-Android 12+ (SDK 31). All other devices use the XNNPACK/CPU chain.--## Building the Rust photos crate for iOS outside Xcode--The iOS `ort` dependency does not download prebuilt binaries; the-`ente_photos_rust` build phase exports `ORT_LIB_PATH` pointing at the custom-static archive inside the `EnteOnnxRuntime` pod. For direct `cargo`-invocations against an iOS target (for example `cargo check`), run-`pod install` in `mobile/apps/photos/ios` once, then export it manually:--```sh-ORT_LIB_PATH="$PWD/mobile/apps/photos/ios/Pods/EnteOnnxRuntime/onnxruntime.xcframework/ios-arm64" \-IPHONEOS_DEPLOYMENT_TARGET=15.1 \-cargo check -p ente-photos --target aarch64-apple-ios-```--Use the `ios-arm64-simulator` slice and `--target aarch64-apple-ios-sim` for-the Simulator. The deployment target must be at least 15.1 to match the-archive.diff --git a/rust/crates/ensu/Cargo.toml b/rust/crates/ensu/Cargo.tomlindex 7636641c54..1e85c33b9b 100644--- a/rust/crates/ensu/Cargo.toml+++ b/rust/crates/ensu/Cargo.toml@@ -57,7 +57,7 @@ llama-cpp-2 = { version = "=0.1.144", features = ["mtmd"] }ort = { workspace = true, features = ["load-dynamic"], optional = true }# The iOS app links Ente's custom ONNX Runtime XCFramework via SPM, so ort-sys-# must not download/link pyke's binaries. See mobile/native/onnxruntime/README.md.+# must not download/link pyke's binaries. See mobile/native/onnxruntime.md.[target.'cfg(target_os = "ios")'.dependencies]ort-sys = { workspace = true, features = ["disable-linking"], optional = true }diff --git a/rust/crates/photos/Cargo.toml b/rust/crates/photos/Cargo.tomlindex 82cf74f330..dae8aebe86 100644--- a/rust/crates/photos/Cargo.toml+++ b/rust/crates/photos/Cargo.toml@@ -26,7 +26,7 @@ usearch = "=2.21.4"# ORT source and revision are pinned once in the workspace manifest; only the# per-target feature sets are declared here.# The iOS Cargokit build sets ORT_LIB_PATH to the directory containing the-# verified custom static archive; see mobile/native/onnxruntime/README.md for+# verified custom static archive; see mobile/native/onnxruntime.md for# building outside Xcode.[target.'cfg(target_os = "ios")'.dependencies]ort = { workspace = true, features = [