Skip to content

fix(commons): iOS model download never completes - #907

Merged
fbernaly merged 1 commit into
flutter-ml:developfrom
DDefiebre:fix/commons-ios-model-download-notifications
Oct 26, 2026
Merged

fbernaly merged 1 commit into
flutter-ml:developfrom
DDefiebre:fix/commons-ios-model-download-notifications

Conversation

@DDefiebre

Copy link
Copy Markdown
Contributor

Fixes #906

GenericModelManager observed .mlkitModelDownloadDidSucceed / .mlkitModelDownloadDidFail with object: model. ML Kit posts both notifications with its own manager/downloader as the sender and passes the model only in userInfo[ModelDownloadUserInfoKey.remoteModel], so the observers never fired and ModelManager.downloadModel() never returned on iOS when a model actually had to be downloaded.

This change observes with object: nil and matches the model from userInfo, as shown in the ML Kit iOS documentation ("Explicitly manage translation models"). RemoteModel implements isEqual:, so == also matches another instance of the same model. The result sent to Dart is unchanged (success / error).

Regression from the Objective-C → Swift migration (#844). The Objective-C implementation observed with object:nil.

Verified

  • git apply --check on develop (1083593)
  • swiftc -typecheck (Swift 5, arm64-apple-ios15.5, iPhoneOS SDK) against the real Flutter.framework and MLKitCommon.framework: no errors or warnings, before and after

Not verified

  • Not run on a device or in the example app

🤖 Generated with Claude Code

GenericModelManager observed .mlkitModelDownloadDidSucceed/.mlkitModelDownloadDidFail
with `object: model`. ML Kit posts both notifications with its own manager/downloader
as the sender and the model only in userInfo[ModelDownloadUserInfoKey.remoteModel],
so the observers never fired and ModelManager.downloadModel() never returned on iOS
for a model that was not yet on the device.

Observe with `object: nil` and match the model from userInfo, as shown in the
ML Kit iOS documentation. Regression from the Objective-C to Swift migration (flutter-ml#844).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fbernaly
fbernaly merged commit 65aa11d into flutter-ml:develop Oct 26, 2026
4 checks passed
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.

[commons][iOS] ModelManager.downloadModel() never completes: GenericModelManager observes the download notifications with object: model

2 participants