bug(camera): chooseFromGallery blocks the main thread on iOS while the photo grid opens
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- ios, swift
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 687
- フォーク
- 691
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ionic-team/capacitor-plugins のほかの issue
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ionic-team/capacitor-plugins#2616 ·
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageオープンtriage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
ionic-team/capacitor-plugins#2604 ·
-
bug(network): Android networkStatusChange re-queries the active network inside callbacks and fires on every capability change対応中かも @kcjonson が 3 日前に担当しました。 オープンplatform: android
難易度 4/5 1〜2日 初心者へのやさしさ 25/100
ionic-team/capacitor-plugins#2621 ·
-
bug(network): iOS getStatus() returns the last reachability callback value instead of reading current flags対応中かも @kcjonson が 3 日前に担当しました。 オープンplatform: ios
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
ionic-team/capacitor-plugins#2620 ·
-
platform: android platform: ios
難易度 5/5 1週間以上 初心者へのやさしさ 24/100
ionic-team/capacitor-plugins#2619 ·
ionic-team/capacitor-plugins の issue をすべて見る
似ている issue
-
staticAssetsPath follows symlinks outside the directory on Windows対応中かも @ybelMekk が今日担当しました。 オープンbug security findings
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
navikt/mock-oauth2-server#1132 ·
メンテナーはふだん 1 日以内に返信
-
agent:working follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Sanne/incus-spawn#1683 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
checkstyle/checkstyle#22210 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
google/error-prone#6239 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Failing Test]: BigqueryClient.queryUnflattened fails BigQuery ITs on a transient 503対応中かも @mxtymoshyk が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信