existsSync in CacheStore._removeCachedFile blocks the main isolate (ANR on Android)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 22/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- android
- 領域
- mobile, performance
調査の方向性
The synchronous call is existsSync() inside CacheStore._removeCachedFile, which the issue says is shared by the cleanup, removeFile and emptyCache paths; the other checks it lists already use exists(). Start there and look at the existing removal tests, which fake the file system through Config. Done means that call is asynchronous and those tests still pass. Pull request #540 is already open against this issue, so check its status before starting.
索引モデルが issue の本文から書いたものです。
説明
🐛 Bug Report
CacheStore._removeCachedFile checks whether the cached file exists with the synchronous existsSync(). Every removal path goes through it: the periodic cleanup scheduled after a cache read, removeFile and emptyCache, including the DefaultCacheManager that cached_network_image uses.
Since Flutter 3.29, the UI thread and the platform thread are merged on Android. Synchronous file I/O on the main isolate therefore blocks the Android main thread, and a slow storage stall turns into an ANR. Our production app (Flutter 3.47) reports ANRs whose main-thread stack ends like this:
fstatat
dart::bin::File::Exists
_File.existsSync
ForwardingFileSystemEntity.existsSync
CacheStore._removeCachedFile
main (3.4.5) still has the same line. The rest of the removal path, and other existence checks in the package (_fileExists, WebHelper._removeOldFile, the repositories), already use the asynchronous exists().
Expected behavior
Removing cached files does not run synchronous file system calls on the calling isolate, for example by using await file.exists() instead of file.existsSync().
Reproduction steps
The ANR depends on storage latency and does not reproduce on demand. The synchronous call can be shown deterministically:
- Create a
ConfigwhoseFileSystem.createFilereturns aFilewhoseexistsSync()throws. - Call
CacheStore.removeCachedFile(orCacheManager.removeFile/emptyCache) for an entry whose file exists. existsSync()is called and the removal fails.
Configuration
Version: 3.4.5 (also 3.4.2)
Platform:
- 📱 iOS
- 🤖 Android
- 主要言語
- Dart
- スター
- 814
- フォーク
- 513
- 平均マージ
- 28分
- マージ済み PR(30日)
- 12
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Baseflow/flutter_cache_manager のほかの issue
-
JsonCacheInfoRepository: FormatException: Unexpected end of input (at character 1) ^対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Baseflow/flutter_cache_manager#450 · コメント 9 件 · リアクション 8 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
Baseflow/flutter_cache_manager#535 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
Baseflow/flutter_cache_manager#508 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
Baseflow/flutter_cache_manager#507 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
Baseflow/flutter_cache_manager#501 · コメント 1 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
Baseflow/flutter_cache_manager の issue をすべて見る
似ている issue
-
agent:in-progress agent:ready feature P2 · 中 区域: 悬浮窗
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
ASDW51/DanmuFloat#178 ·
メンテナーはふだん 1 日以内に返信
-
Missing workoutsオープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
InlitX/GymMane#237 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
AppFlowy-IO/AppFlowy#9077 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Abhinivesh2729/Thinai#41 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
0niel/university-app#617 ·
メンテナーはふだん 1 日以内に返信