facebook/fresco

Occasionally throws FileNotFoundException by reading files after inserting to main disk cache concurrently

Open

#2,382 建立於 2019年7月23日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)Java (17,072 star) (3,750 fork)batch import
bughelp wanted

描述

For more details please refer to this repo including a detailed README and a runnable Android app: https://github.com/JuniperPhoton/FrescoFileNotFoundBug

Description

This is an issue on this situation:

Massively and concurrently fetching images from network and insert them into disk cache immediately, and then read the files on the same thread.

By saying Massively and concurrently I mean doing the work on every 50ms, please refer to MainActivity for more details.

The issue is that sometimes it throws java.io.FileNotFoundException on reading saved files by opening a FileInputStream, even if the files do exist. The files can still be found using Android Studio's Device File Explorer can of course be opened.

Furthermore, if you try to open the file exported by content:// by other apps, or do a thread sleeping before accessing them, it will work.

Reproduction

Please refer to this repo: https://github.com/JuniperPhoton/FrescoFileNotFoundBug

Solution

Please refer to this repo: https://github.com/JuniperPhoton/FrescoFileNotFoundBug

Additional Information

  • Fresco version: 2.0.0
  • Platform version: No devices or OS version specified, tested on Android P/Q, Pixel 2 and OnePlus 7 Pro

貢獻者指南