bug(camera): chooseFromGallery blocks the main thread on iOS while the photo grid opens
Maintainer thường phản hồi trong vòng 29 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- ios, swift
- Lĩnh vực
- mobile-dev, performance
Hướng nghiên cứu
Start with Sources/IONCameraLib/Interfaces/PhotoLibrary/IONCAMRPhotoLibraryView.swift, especially lines 82-114, and reproduce on an iOS device with a large photo library. Inspect the grid construction, scrollTo behavior, and selectedAssetArray checks while measuring main-thread work. Done means chooseFromGallery opens without a library-size-dependent freeze.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
Plugin(s)
@capacitor/camera 8.2.0 (iOS, via IONCameraLib 1.0.4). The affected code is unchanged in IONCameraLib 1.0.5 and 2.0.0.
Capacitor Version
@capacitor/core: 8.4.1
@capacitor/ios: 8.4.1
@capacitor/cli: 8.4.1
@capacitor/camera: 8.2.0
Platform(s)
iOS
Current Behavior
When Camera.chooseFromGallery() opens the photo grid, the main thread can freeze for several seconds. Our production app reported an App Hang of 2.4–3.2 s on an iPhone 15 Pro running iOS 26.6.1.
The main-thread stack is inside IONCAMRPhotoLibraryView.body, building grid cells:
swift_retain
IONCAMRPhotoLibraryView.selectedAssetArray.getter
closure in IONCAMRPhotoLibraryView.body.getter (IONCAMRPhotoLibraryView.swift:98)
Button.init
closure in IONCAMRPhotoLibraryView.body.getter (IONCAMRPhotoLibraryView.swift:86)
ZStack.init
closure in IONCAMRPhotoLibraryView.body.getter (IONCAMRPhotoLibraryView.swift:83)
closure in ForEachState.item
... (SwiftUI layout frames)
closure in IONCAMRPhotoLibraryView.body.getter (IONCAMRPhotoLibraryView.swift:114)
...
main
Expected Behavior
The gallery opens without blocking the main thread, however many assets are in the library.
Code Reproduction
We don't have a standalone sample app yet. The call is:
await Camera.chooseFromGallery({
mediaType: MediaTypeSelection.Photo,
allowMultipleSelection: false,
quality: 90,
targetWidth: 1200,
targetHeight: 1200,
correctOrientation: true,
});
Steps:
- Use an iOS device with a large photo library (thousands of assets) and full photo access.
- Call
Camera.chooseFromGallery()as above. - The UI freezes while the grid appears. The freeze should get longer as the library grows.
Other Technical Details
- Seen in production on iPhone 15 Pro, iOS 26.6.1 (23G83). The device's thermal state was "serious", so it was probably throttled.
Additional Context
The likely cause, from reading IONCAMRPhotoLibraryView.swift:
ForEach(photoLibraryService.results, id: \.self) { asset in ... } // line 82: every asset in the library
...
.onAppear {
value.scrollTo(photoLibraryService.results.startElement, anchor: .bottom) // line 114
}
scrollToon appear jumps to the far end of aLazyVGridthat holds the whole library. Our stack shows that line 114 makes SwiftUI buildForEachcells on the main thread, so the work likely grows with library size.- Each cell also calls
selectedAssetArray.contains(asset)twice (lines 98 and 101). That's a linear search per cell, run on every body evaluation.
- Ngôn ngữ chính
- Java
- Star
- 688
- Fork
- 692
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ionic-team/capacitor-plugins
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ionic-team/capacitor-plugins#2616 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageĐang mởtriage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
ionic-team/capacitor-plugins#2604 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
platform: ios
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ionic-team/capacitor-plugins#2624 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
bug(network): Android networkStatusChange re-queries the active network inside callbacks and fires on every capability changeCó thể đã có người làm @kcjonson đã nhận 10 ngày trước. Đang mởplatform: android
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 25/100
ionic-team/capacitor-plugins#2621 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
bug(network): iOS getStatus() returns the last reachability callback value instead of reading current flagsCó thể đã có người làm @kcjonson đã nhận 10 ngày trước. Đang mởplatform: ios
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
ionic-team/capacitor-plugins#2620 ·
Maintainer thường phản hồi trong vòng 29 ngày
Tất cả issue của ionic-team/capacitor-plugins
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Shweit/EtherealPortals#30 ·
-
Typo in jakartaee-bom 12.0.0-SNAPSHOT with cdiCó thể đã có người làm @ElectLive đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
jakartaee/jakartaee-api#205 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
liberation-data/drivine4j#547 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
BindingServiceProperties.bindings regressed to a non-thread-safe TreeMap in GH-3158: concurrent first use of binding names corrupts itCó thể đã có người làm @AkashB23 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
spring-cloud/spring-cloud-stream#3321 ·
Maintainer thường phản hồi trong vòng 1 ngày