existsSync in CacheStore._removeCachedFile blocks the main isolate (ANR on Android)
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
- Área
- mobile, performance
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:
- 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
- Lenguaje dominante
- Dart
- Estrellas
- 814
- Forks
- 513
- Merge medio
- 28 min
- PR fusionados (30 d)
- 12
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Baseflow/flutter_cache_manager
-
JsonCacheInfoRepository: FormatException: Unexpected end of input (at character 1) ^Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Baseflow/flutter_cache_manager#450 · 9 comentarios · 8 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Baseflow/flutter_cache_manager#535 ·
Los mantenedores suelen responder en 1 día
-
Retaining original file namesAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
Baseflow/flutter_cache_manager#508 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
Baseflow/flutter_cache_manager#507 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
sqflite_android updateAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 30/100
Baseflow/flutter_cache_manager#501 · 1 comentario · 3 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de Baseflow/flutter_cache_manager
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
good-first-issue P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
flutter/dart-intellij-third-party#758 ·
Los mantenedores suelen responder en 1 día
-
Bug: Incorrect location coordinates on logged Sound Meter dataPosiblemente ocupada @Jashan32 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
area/archive bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
DarkFlippers/qUnleashed#374 ·
Los mantenedores suelen responder en 1 día