existsSync in CacheStore._removeCachedFile blocks the main isolate (ANR on Android)
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:
- 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
- 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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Baseflow/flutter_cache_manager
-
JsonCacheInfoRepository: FormatException: Unexpected end of input (at character 1) ^Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Baseflow/flutter_cache_manager#450 · 9 bình luận · 8 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Baseflow/flutter_cache_manager#535 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Retaining original file namesĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Baseflow/flutter_cache_manager#508 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
Baseflow/flutter_cache_manager#507 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sqflite_android updateĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
Baseflow/flutter_cache_manager#501 · 1 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Baseflow/flutter_cache_manager
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
chriskelly/wish-together#36 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Web Guide has broken linksĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AppFlowy-IO/AppFlowy#9075 ·
-
Paste asks for iOS paste permission because the default context menu ignores SystemContextMenuCó thể đã có người làm @dorklein đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
maheshj01/searchfield#267 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
hajisensai/Fushi#2340 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày