Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#539 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@yamashita-room-335 arbeitet bereits daran.

Seit 13.10.2026.

  • #540 von @yamashita-room-335 — offen

Bewertung

Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Anfängerfreundlichkeit
22/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
android
Bereich
mobile, performance

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

🐛 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
Vorherrschende Sprache
Dart
Sterne
814
Forks
513
Ø Merge
28 Min.
Gemergte PRs (30 T.)
12

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Baseflow/flutter_cache_manager

Alle Issues in Baseflow/flutter_cache_manager

Ähnliche Issues

Weitere Issues zu Dart

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.