A corner case check in Instance::handleMemoryPressure

Summary:
At some early stages of Instance initialization, it does not have a `nativeToJsBridge_`. At the same time, `handleMemoryPressure` can be called at any point in time, so we should check the pointer for not being null before calling on it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D21798522

fbshipit-source-id: 6384da88784cceb493cf9810408cbb47777d3f4b
This commit is contained in:
Valentin Shergin authored and Facebook GitHub Bot committed 2020-05-29 20:38:25 -07:00
1 parent b99bdaa218
commit 9d6d39de86
1 file changed
+5 -1
+5 -1
View File
@@ -222,7 +222,11 @@ ModuleRegistry &Instance::getModuleRegistry() {
}
void Instance::handleMemoryPressure(int pressureLevel) {
nativeToJsBridge_->handleMemoryPressure(pressureLevel);
if (nativeToJsBridge_) {
// This class resets `nativeToJsBridge_` only in the destructor,
// hence a race is not possible there.
nativeToJsBridge_->handleMemoryPressure(pressureLevel);
}
}
std::shared_ptr<CallInvoker> Instance::getJSCallInvoker() {