Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#539 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@yamashita-room-335 đang làm issue này rồi.

Từ ngày 13/10/2026.

  • #540 của @yamashita-room-335 — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
android
Lĩnh vực
mobile, performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

🐛 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
Ngôn ngữ chính
Dart
Star
814
Fork
513
Merge trung bình
28 phút
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Baseflow/flutter_cache_manager

Tất cả issue của Baseflow/flutter_cache_manager

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.