Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改小游戏平台加载远程资源之后,会在一段时间内间隔2秒左右出现一次卡顿掉帧的问题 #16761

Closed
wants to merge 1 commit into from

Conversation

pengchengo
Copy link

https://forum.cocos.org/t/topic/156157
在小游戏平台远程加载资源之后,会在一段时间内间隔2秒左右出现一次卡顿掉帧。测试是在字节小游戏使用iphone11和iPhone13.
定位到问题是在加载远程资源以后,引擎会间隔2秒从临时目录保存到缓存,这里用的是writeFileSync同步方法,打印时间70ms左右,writeFileSync会导致游戏主线程卡主,应该改为writeFile方法异步写入

Copy link

Interface Check Report

This pull request does not change any public interfaces !

@zhefengzhang
Copy link
Contributor

zhefengzhang commented Mar 4, 2024

有个情况需要考虑下。因为引擎会先把缓存路径保存到 assetManager._files 中,然后再由缓存管理器将资源写入到缓存中,如果存在资源写入未完全结束,但是却需要加载某个 assetManager._files 中的缓存资源,就可能导致读取不到缓存中的资源而报错。

@zhefengzhang
Copy link
Contributor

此 pr 的改动在实际的项目中暂未发现导致加载出错的异常,所以如果项目有需求的话可以考虑直接使用。但是如果引擎要合并的话就需要确保异步加载不会导致一些理论上的小概率问题。

@minggo minggo assigned minggo and unassigned minggo Apr 16, 2024
@minggo minggo deleted the branch cocos:v3.8.3 May 16, 2024 02:51
@minggo minggo closed this May 16, 2024
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.

None yet

3 participants