增加格式化,修改ts语法,解决cocos在字节小游戏上下载文件,每隔2秒掉帧到30-40帧的问题。原因是_write方法里使用writeF…#82
Closed
pengchengo wants to merge 2 commits intococos:v4.0.0from
Hidden character warning
The head ref may contain hidden characters: "\u89e3\u51b3\u5b57\u8282\u5361\u987f\u95ee\u98982"
Closed
增加格式化,修改ts语法,解决cocos在字节小游戏上下载文件,每隔2秒掉帧到30-40帧的问题。原因是_write方法里使用writeF…#82pengchengo wants to merge 2 commits intococos:v4.0.0from
pengchengo wants to merge 2 commits intococos:v4.0.0from
Conversation
…ileSync方法在字节小游戏上可能时长700ms,卡主游戏。修改方法是改成2.x的版本使用异步方法writeFile,cache-manager基本改成和2.x一样了
6 tasks
bofeng-song
reviewed
Feb 27, 2026
| else { | ||
| copyFile(srcUrl, localPath, callback); | ||
| } | ||
| return; |
Contributor
Author
|
这和cocos2.4.15的写法是保持一致的,实际只会执行cacheQueue的第一个,执行完成在callback里面会再执行cacheQueue的下一个。简化代码应该可以不用for循环只取第一个元素就行,目前保持和2.x一致就没改。
原始邮件
发件人:bofeng-song ***@***.***>
发件时间:2026年2月27日 17:40
收件人:cocos/cocos4 ***@***.***>
抄送:pengchengo ***@***.***>, Author ***@***.***>
主题:Re: [cocos/cocos4] 增加格式化,修改ts语法,解决cocos在字节小游戏上下载文件,每隔2秒掉帧到30-40帧的问题。原因是_write方法里使用writeF… (PR #82)
@bofeng-song commented on this pull request.
In platforms/minigame/common/engine/cache-manager.js:
> } + else { + copyFile(srcUrl, localPath, callback); + } + return;
return 多余?逻辑不一致了?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
bofeng-song
reviewed
Feb 28, 2026
| setTimeout(deferredDelete, self.deleteInterval); | ||
| } else { | ||
| cleaning = false; | ||
|
|
Contributor
There was a problem hiding this comment.
clearTimeout(writeCacheFileList); 没必要执行?
bofeng-song
reviewed
Feb 28, 2026
| clearTimeout(writeCacheFileList); | ||
| this._write(); | ||
| cc.assetManager.bundles.forEach((bundle) => { | ||
| writeFileSync(cacheFilePath, JSON.stringify({ files: this.cachedFiles._map, version: this.version }), 'utf8'); |
Contributor
There was a problem hiding this comment.
这里不需要执行 clearTimeout(writeCacheFileList);?
writeCacheFileList有赋值,没必要clear?
bofeng-song
reviewed
Feb 28, 2026
| clearTimeout(writeCacheFileList); | ||
| this._write(); | ||
| this._removePathOrFile(url, path); | ||
| this.writeCacheFile(function () { |
Contributor
There was a problem hiding this comment.
clearTimeout(writeCacheFileList); 没必要执行?
Contributor
Author
|
应该不需要,writeCacheFile方法中有判断writeCacheFileList为空才延迟执行_write,如果clearTimeout只是重新执行了下writeCacheFile,比之前就是重新延迟2秒执行_write,就是执行时间的区别,逻辑没啥区别
pengchengo
***@***.***
原始邮件
发件人:bofeng-song ***@***.***>
发件时间:2026年2月28日 11:08
收件人:cocos/cocos4 ***@***.***>
抄送:pengchengo ***@***.***>, Author ***@***.***>
主题:Re: [cocos/cocos4] 增加格式化,修改ts语法,解决cocos在字节小游戏上下载文件,每隔2秒掉帧到30-40帧的问题。原因是_write方法里使用writeF… (PR #82)
@bofeng-song commented on this pull request.
In platforms/minigame/common/engine/cache-manager.js:
> const path = this.cachedFiles.remove(url).url; - clearTimeout(writeCacheFileList); - this._write(); - this._removePathOrFile(url, path); + this.writeCacheFile(function () {
clearTimeout(writeCacheFileList); 没必要执行?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
tangkaikk
reviewed
Mar 2, 2026
Contributor
tangkaikk
left a comment
There was a problem hiding this comment.
deferredDelete 差异比较大。这块需要恢复到之前的逻辑。否则在其他平台会有问题。
| cleaning = false; | ||
|
|
||
| this.writeCacheFile(function () { | ||
| function deferredDelete () { |
Contributor
There was a problem hiding this comment.
deferredDelete 差异比较大。这块需要恢复到之前的逻辑。否则在其他平台会有问题。
Contributor
Author
|
好的,我看看
pengchengo
***@***.***
|
Contributor
Author
|
参考2.4.16改了下 #85
pengchengo
***@***.***
原始邮件
发件人:tangkai ***@***.***>
发件时间:2026年3月2日 11:16
收件人:cocos/cocos4 ***@***.***>
抄送:pengchengo ***@***.***>, Author ***@***.***>
主题:Re: [cocos/cocos4] 增加格式化,修改ts语法,解决cocos在字节小游戏上下载文件,每隔2秒掉帧到30-40帧的问题。原因是_write方法里使用writeF… (PR #82)
@tangkaikk commented on this pull request.
In platforms/minigame/common/engine/cache-manager.js:
> @@ -194,27 +218,41 @@ const cacheManager = { cc.assetManager.files.remove(cacheKey); this.cachedFiles.remove(caches[i].originUrl); } - - clearTimeout(writeCacheFileList); - this._write(); - function deferredDelete () { - const item = caches.pop(); - self._removePathOrFile(item.originUrl, item.url); - if (caches.length > 0) { - setTimeout(deferredDelete, self.deleteInterval); - } else { - cleaning = false; + + this.writeCacheFile(function () { + function deferredDelete () {
或者参考2.4.16的代码来修改,会比较全面。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ileSync方法在字节小游戏上可能时长700ms,卡主游戏。修改方法是改成2.x的版本使用异步方法writeFile,cache-manager基本改成和2.x一样了
Re: #
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: