Skip to content

增加格式化,修改ts语法,解决cocos在字节小游戏上下载文件,每隔2秒掉帧到30-40帧的问题。原因是_write方法里使用writeF…#82

Closed
pengchengo wants to merge 2 commits intococos:v4.0.0from
pengchengo:解决字节卡顿问题2

Hidden character warning

The head ref may contain hidden characters: "\u89e3\u51b3\u5b57\u8282\u5361\u987f\u95ee\u98982"

Conversation

@pengchengo
Copy link
Copy Markdown
Contributor

…ileSync方法在字节小游戏上可能时长700ms,卡主游戏。修改方法是改成2.x的版本使用异步方法writeFile,cache-manager基本改成和2.x一样了

Re: #

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

…ileSync方法在字节小游戏上可能时长700ms,卡主游戏。修改方法是改成2.x的版本使用异步方法writeFile,cache-manager基本改成和2.x一样了
else {
copyFile(srcUrl, localPath, callback);
}
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 多余?逻辑不一致了?

@pengchengo
Copy link
Copy Markdown
Contributor Author

pengchengo commented Feb 28, 2026 via email

setTimeout(deferredDelete, self.deleteInterval);
} else {
cleaning = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearTimeout(writeCacheFileList); 没必要执行?

clearTimeout(writeCacheFileList);
this._write();
cc.assetManager.bundles.forEach((bundle) => {
writeFileSync(cacheFilePath, JSON.stringify({ files: this.cachedFiles._map, version: this.version }), 'utf8');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要执行 clearTimeout(writeCacheFileList);?
writeCacheFileList有赋值,没必要clear?

clearTimeout(writeCacheFileList);
this._write();
this._removePathOrFile(url, path);
this.writeCacheFile(function () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearTimeout(writeCacheFileList); 没必要执行?

@pengchengo
Copy link
Copy Markdown
Contributor Author

pengchengo commented Feb 28, 2026 via email

Copy link
Copy Markdown
Contributor

@tangkaikk tangkaikk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferredDelete 差异比较大。这块需要恢复到之前的逻辑。否则在其他平台会有问题。

cleaning = false;

this.writeCacheFile(function () {
function deferredDelete () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferredDelete 差异比较大。这块需要恢复到之前的逻辑。否则在其他平台会有问题。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者参考2.4.16的代码来修改,会比较全面。

@pengchengo
Copy link
Copy Markdown
Contributor Author

pengchengo commented Mar 2, 2026 via email

@pengchengo
Copy link
Copy Markdown
Contributor Author

pengchengo commented Mar 2, 2026 via email

@pengchengo pengchengo closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants