existsSync in CacheStore._removeCachedFile blocks the main isolate (ANR on Android)
Mantenedores costumam responder em até 1 dia
@yamashita-room-335 já está trabalhando nisso.
Desde 13/10/2026.
- #540 de @yamashita-room-335 — aberto
Avaliação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Facilidade para iniciantes
- 22/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- android
- Domínio
- mobile, performance
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
🐛 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
- Linguagem predominante
- Dart
- Estrelas
- 814
- Forks
- 513
- Merge médio
- 28min
- PRs com merge (30d)
- 12
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de Baseflow/flutter_cache_manager
-
JsonCacheInfoRepository: FormatException: Unexpected end of input (at character 1) ^Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Baseflow/flutter_cache_manager#450 · 9 comentários · 8 reações ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
Baseflow/flutter_cache_manager#535 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
Baseflow/flutter_cache_manager#508 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 48/100
Baseflow/flutter_cache_manager#507 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
sqflite_android updateAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 30/100
Baseflow/flutter_cache_manager#501 · 1 comentário · 3 reações ·
Mantenedores costumam responder em até 1 dia
Todas as issues de Baseflow/flutter_cache_manager
Issues semelhantes
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 65/100
chriskelly/wish-together#36 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
AppFlowy-IO/AppFlowy#9075 ·
-
Paste asks for iOS paste permission because the default context menu ignores SystemContextMenuTalvez já em andamento @dorklein assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
maheshj01/searchfield#267 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
avdept/JellyBoxPlayer#375 ·
Mantenedores costumam responder em até 1 dia