Reduce VisionKit scan memory by streaming page processing#37
Reduce VisionKit scan memory by streaming page processing#37
Conversation
Co-authored-by: riderx <4084527+riderx@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d10fb5627
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private func finishScan(with scan: VNDocumentCameraScan) { | ||
| processImages(pageCount: limitedPageCount(total: scan.pageCount)) { index in | ||
| scan.imageOfPage(at: index) | ||
| } | ||
| } |
There was a problem hiding this comment.
Route VisionKit scans through the streaming processor
The new finishScan(with scan: VNDocumentCameraScan) path is never used, so the real-device VisionKit flow still materializes all pages first in didFinishWith scan ((0..<scan.pageCount).map(...)) and then calls the [UIImage] overload. That keeps the original peak-memory behavior this commit is trying to remove, so multi-page scans on low-memory devices can still trigger webview/process restarts. The delegate should call the VNDocumentCameraScan overload directly so pages are processed one-by-one.
Useful? React with 👍 / 👎.
|
@copilot fix the comment and mark them resolve |
Agent-Logs-Url: https://github.com/Cap-go/capacitor-document-scanner/sessions/f7f5a677-dd15-49f4-b8b9-9fb1dd33405e Co-authored-by: riderx <4084527+riderx@users.noreply.github.com>
Lower-end iPhones were restarting the webview due to VNDocumentCameraViewController memory spikes during multi-page scans.
autoreleasepool, avoiding retention of all images simultaneously.finishScan(with scan:)processes VisionKit scans page-by-page via a lightweight provider.limitedPageCount; response generation unchanged but now per-page.