[Android] 0.28.0源码 调用 fireEvent(..., EventResult callback),无回调或仅有一次回调
- Dominant language
- C++
- Stars
- 18.5k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
问题是因为在 `script_bridge_in_multi_process.cpp` 的 `std::unique_ptr OnReceivedResult(IPCArguments *arguments)` 方法中,获取`callback_id`的方式`long callback_id = arguments->get(0); `总返回 1或0,导致java层找不到对应的回调监听。
**详情如下:**
```
std::unique_ptr OnReceivedResult(IPCArguments *arguments) {
/**
* START
* 2021/06/16
* 原代码 long callback_id = arguments->get(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 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 &>(result));
}));
return createInt32Result(static_cast(true));
}
```
Contributor guide
Research direction
Start in script_bridge_in_multi_process.cpp at OnReceivedResult(IPCArguments *arguments), then trace how callback_id reaches the Java callback listener through the script bridge. Reproduce fireEvent with an EventResult callback and verify that the callback is consistently delivered rather than missing or firing only once.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, cpp
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100