feat:fix when android excute js on same thread,cause stucked
This commit is contained in:
@@ -93,7 +93,7 @@ function _rawValue(v) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function _injectGlobalObject(name, args) {
|
||||
function __injectGlobalObject(name, args) {
|
||||
Reflect.set(window, name, JSON.parse(args));
|
||||
}
|
||||
function __injectGlobalFunction(name) {
|
||||
@@ -107,6 +107,7 @@ function __injectGlobalFunction(name) {
|
||||
});
|
||||
}
|
||||
function __invokeMethod(objectName, functionName, stringifiedArgs) {
|
||||
NativeClient.log(`invoke:${objectName}.${functionName}(${stringifiedArgs})`);
|
||||
try {
|
||||
const thisObject = Reflect.get(window, objectName);
|
||||
const thisFunction = Reflect.get(thisObject, functionName);
|
||||
@@ -114,6 +115,7 @@ function __invokeMethod(objectName, functionName, stringifiedArgs) {
|
||||
const rawArgs = args.map(e => _rawValue(e));
|
||||
const ret = Reflect.apply(thisFunction, thisObject, rawArgs);
|
||||
const returnVal = ret ? JSON.stringify(_wrappedValue(ret)) : "";
|
||||
NativeClient.log(`return:${returnVal}`);
|
||||
NativeClient.returnNative(returnVal);
|
||||
}
|
||||
catch (e) {
|
||||
|
Reference in New Issue
Block a user