mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
make runtime reference thread safe on tickleJs call
Summary: The reference to runtime assumes the queue will ensure references to runtime are valid when invoked. This isn't the case if you create a breakpoint, Hermes hit that breakpoint and your refresh the app. This consistently will crash the app. The fix is to not assument this, similar to ReactCommon/react/runtime/hermes/HermesInstance.cpp Reviewed By: javache Differential Revision: D50225678 fbshipit-source-id: b45cae1f5f687bc8c699fd74b187376a547012c5
This commit is contained in:
@@ -43,13 +43,16 @@ class HermesExecutorRuntimeAdapter
|
||||
}
|
||||
|
||||
void tickleJs() override {
|
||||
// The queue will ensure that runtime_ is still valid when this
|
||||
// gets invoked.
|
||||
thread_->runOnQueue([&runtime = runtime_]() {
|
||||
auto func =
|
||||
runtime->global().getPropertyAsFunction(*runtime, "__tickleJs");
|
||||
func.call(*runtime);
|
||||
});
|
||||
thread_->runOnQueue(
|
||||
[weakRuntime = std::weak_ptr<HermesRuntime>(runtime_)]() {
|
||||
auto runtime = weakRuntime.lock();
|
||||
if (!runtime) {
|
||||
return;
|
||||
}
|
||||
jsi::Function func =
|
||||
runtime->global().getPropertyAsFunction(*runtime, "__tickleJs");
|
||||
func.call(*runtime);
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user