-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fixed #17012: Loading assets synchronously causes rendering to freeze. #17464
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
14 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -34479,8 +34479,29 @@
*
*/
function getStringFromFile(filename: string): string;
/**
+ * @en Read utf-8 text file asynchronously.
+ * @zh 异步读取 utf-8 编码的文本文件
+ * @param filepath @en The file path. @zh 文件路径
+ * @param onComplete @en The complete callback. @zh 读取完成回调
+ */
+ function readTextFile(filepath: string, onComplete: (err: string | null, content: string) => void): void;
+ /**
+ * @en Read utf-8 json file asynchronously.
+ * @zh 异步读取 utf-8 编码的 json 文件
+ * @param filepath @en The file path. @zh 文件路径
+ * @param onComplete @en The complete callback. @zh 读取完成回调
+ */
+ function readJsonFile(filepath: string, onComplete: (err: string | null, content: object) => void): void;
+ /**
+ * @en Read binary file asynchronously.
+ * @zh 异步读取二进制文件
+ * @param filepath @en The file path. @zh 文件路径
+ * @param onComplete @en The complete callback. @zh 读取完成回调
+ */
+ function readDataFile(filepath: string, onComplete: (err: string | null, content: ArrayBuffer) => void): void;
+ /**
* @en
* Removes a file.
*
* @zh
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
@@ -1526,7 +1526,7 @@ SE_BIND_FUNC(JSB_openharmony_postSyncMessage) | |||
#endif | |||
|
|||
bool jsb_register_global_variables(se::Object *global) { // NOLINT | |||
gThreadPool = LegacyThreadPool::newFixedThreadPool(3); | |||
gIOThreadPool = LegacyThreadPool::newFixedThreadPool(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be lots of json/ccb files to be loaded, so add 2 more threads in pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
@cocos-robot run test cases |
…84-native-async-load
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
74 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
@dumganhar, Please check the result of
Task Details |
@dumganhar, Please check the result of
Task Details
|
The main thread will not be freezed now and the performance on android is better than before.
Re: #17012
cocos/cocos-engine-external#455
Performance
4324
4326
3194
2877
964
975
662
713
5939
5622
3983
3704
664
647
708
695
755
717
738
729
424
404
452
408
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request:
Greptile Summary
Introduced asynchronous asset loading to prevent rendering freezes, significantly improving performance on Android devices.
native/cocos/bindings/manual/jsb_global.cpp
: Added async image loading and saving functions, leveraging a thread pool.native/cocos/bindings/jswrapper/v8/Utils.h
: EnhancedExternalStringResource
with aDispose
method for better memory management.native/cocos/bindings/manual/jsb_cocos_manual.cpp
: Implemented async asset loading to avoid rendering freezes, focusing on thread pool tasks and JSON parsing.native/external-config.json
: Updated to referencev3.8.4-3
of the external engine-native repository.cocos/native-binding/index.ts
: Introduced async file reading functions (readTextFile
,readJsonFile
,readDataFile
).