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 2020-05-29 20:36:05 -07:00 коммит произвёл Facebook GitHub Bot
Родитель b99bdaa218
Коммит 9d6d39de86
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -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() {