Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

existsSync in CacheStore._removeCachedFile blocks the main isolate (ANR on Android)

オープン
#539 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@yamashita-room-335 がすでに取り組んでいます。

2026年10月13日 から。

  • #540 @yamashita-room-335 による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
android

調査の方向性

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:

  1. Create a Config whose FileSystem.createFile returns a File whose existsSync() throws.
  2. Call CacheStore.removeCachedFile (or CacheManager.removeFile / emptyCache) for an entry whose file exists.
  3. 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Baseflow/flutter_cache_manager のほかの issue

Baseflow/flutter_cache_manager の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。