Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#539 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@yamashita-room-335 ya está trabajando en esto.

Desde el 13/10/2026.

  • #540 de @yamashita-room-335 — abierto

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
android

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

🐛 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
Lenguaje dominante
Dart
Estrellas
814
Forks
513
Merge medio
28 min
PR fusionados (30 d)
12

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Baseflow/flutter_cache_manager

Todos los issues de Baseflow/flutter_cache_manager

Issues similares

Más issues de Dart

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.