googlesamples / googlesamples/mlkit

[Bug report] Progress only updates when the download is complete

Open
#773 0 comments 0 reactions 1 assignee Claimed by @zhouyiself View on GitHub
Dominant language
Kotlin
Stars
4.3k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When downloading a translation language model and calling .observe on the Progress object using \.fractionCompleted, it only updates when the download is finished instead of incrementally updating; the result, updated one time, is 1.0. Thank you in advance.

**To Reproduce**
Example Steps to reproduce the behavior in the sample app:
- open xCode,
- install pod 'GoogleMLKit/Translate', '3.2.0'
- use the following below:
If applicable, please include `code snippet` and `sample input(image, video, text, etc)`
```swift

func downloadModel(language:TranslateLanguage){
let model = TranslateRemoteModel.translateRemoteModel(language: language)
let progress = ModelManager.modelManager().download(
model,
conditions: ModelDownloadConditions(
allowsCellularAccess: true,
allowsBackgroundDownloading: true

)
)
progress.observe(\.fractionCompleted){ progress, _ in
print(progress.fractionCompleted) // only prints 1 .0 only 1 time. Need it to print multiple times and give percentage.
self.downloadProgressHandler!(progress.fractionCompleted,language) // a callback within the class that will go to the Swift UI
}
}

```

**Expected behavior**
Expect

**SDK Info:**
- SDK Name & Version 'GoogleMLKit/Translate', '3.2.0'

**Smartphone:**
- Device/Simulator: IOS simulator, physical iPhone 11
- Device/Simulator OS: iPhone 15 iOS 17.3

**Development Environment:**
*(For Android issue feel free to skip this section)*
- IDE Eversion: Xcode 15.2
- Laptop/Desktop: MacBook Pro m1 2020
- Laptop/Desktop OS/version: Sonoma 14.3

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.