Our project encountered a problem. During the first game play, there was a high probability of a warning of file copy failure, and this warning would appear continuously and cause the game to freeze.
After investigation, it was found that if a large number of files are downloaded in a short period of time, the cache operation of these files will be delayed due to the 500 milliseconds delay of cacheManager cache files.
However, if this delay is too long, the temporary files of the Byte Game engine may not be found when they are referenced again (it may be that the excessive number of temporary files triggers the Byte Game temporary file cleaning mechanism).
However, even if the file is not found, the cacheManager’s _cache method will continue to try to copy the non-existent file, resulting in continuous warnings.
- Creator version: 2.4.4
- Target platform: Android
- Detailed error information, including call stack:
In the demo, the cached id, srcUrl, and localPath fields are printed in the _cache method for debugging.
- Reproduction method:
- Delete the game cache and make sure it is the first time to enter the game (clear the data of Toutiao app in settings)
- Use Toutiao to scan the code to enter the game
- According to the file download prompt, wait for all files (300 files need to be downloaded in the demo) to be downloaded
- After the file download is complete, you need to wait for a few minutes for the number of files cached by cacheManager to reach a certain upper limit (about 400~500 files, you can judge the number of cached files according to the value of localPath printed by the demo).
- After the file reaches the upper limit, a similar warning will appear:
copy file failed: path: ttfile://temp/tma/downloadfile/xxx.json message:copyFile:fail no such file or directory, copyFile xxx => xxx.
From the error report, it seems that cacheManager is constantly trying to copy non-existent files.
- Mobile phone model: Huawei mate20
- Toutiao app version: 8.2.3
- Editor operating system: Windows 10
- Are there any other errors reported by the editor before: No
- Probability of occurrence: Definitely
Demo link: https://pan.baidu.com/s/14XonwS1dRPKhzqLjLsFbCg Extraction code: mfc9