Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#539 0 comentários 0 reações 0 responsáveis Ver no GitHub

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:

  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
Linguagem predominante
Dart
Estrelas
814
Forks
513
Merge médio
28min
PRs com merge (30d)
12

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de Baseflow/flutter_cache_manager

Todas as issues de Baseflow/flutter_cache_manager

Issues semelhantes

Mais issues de Dart

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.