问题是因为在 script_bridge_in_multi_process.cpp
的 std::unique_ptr<IPCResult> OnReceivedResult(IPCArguments *arguments)
方法中,获取 callback_id
的方式 long callback_id = arguments->get<long>(0);
总返回 1或0,导致java层找不到对应的回调监听。
详情如下:
std::unique_ptr<IPCResult> OnReceivedResult(IPCArguments *arguments) {
/**
* START
* 2021/06/16
* 原代码 long callback_id = arguments->get<long>(0); 总返回 1或0
* 导致java层找不到对应的回调监听
*/
const char *callback_id_str = getArumentAsCStr(arguments, 0);
long callback_id;
sscanf(callback_id_str,"%ld",&callback_id);
/**
* END
*/
std::unique_ptr<WeexJSResult> result;
result.reset(new WeexJSResult);
if (arguments->getCount() > 1 && arguments->getType(1) == IPCType::BYTEARRAY &&
arguments->getByteArray(1)->length > 0) {
result->length = arguments->getByteArray(1)->length;
char *string = new char[result->length + 1];
result->data.reset(string);
memset(string, 0, result->length);
memcpy(string, arguments->getByteArray(1)->content, result->length);
string[result->length] = '\0';
}
WeexCoreManager::Instance()->script_thread()->message_loop()->PostTask(
weex::base::MakeCopyable([callback_id, result = std::move(result)]() {
WeexCoreManager::Instance()
->script_bridge()
->core_side()
->OnReceivedResult(
callback_id,
const_cast<std::unique_ptr<WeexJSResult> &>(result));
}));
return createInt32Result(static_cast<int32_t>(true));
}
1条答案
按热度按时间tf7tbtn21#
在合并安卓代码时,同步修改掉 #3225