iOS: Ensure that rendering operations are serialized to prevent timing errors

This commit is contained in:
pengfei.zhou
2022-07-27 14:28:08 +08:00
committed by osborn
parent 5dd7504a37
commit 81137b8fb8
4 changed files with 62 additions and 46 deletions

View File

@@ -109,7 +109,14 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met
const char *retType = methodSignature.methodReturnType;
if (!strcmp(retType, @encode(void))) {
ret = nil;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
DoricThreadMode mode = [target threadMode:methodName];
if (mode == DoricThreadModeUI) {
dispatch_async(dispatch_get_main_queue(), block);
} else if (mode == DoricThreadModeJS) {
block();
} else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
}
} else if (!strcmp(retType, @encode(id))) {
void *retValue;
block();