Gate early EventEmitter update during PreAllocation behind feature flag

Summary:
This feature is still causing some number of crashes, though prod impact is not yet determined. For safety I'm adding a feature flag so we can disable this if necessary.

Changelog: [internal]

Reviewed By: kacieb

Differential Revision: D29117957

fbshipit-source-id: 3b19bac9dd00735f51f5c9cba606378b2a62975e
This commit is contained in:
Joshua Gross
2021-06-14 19:31:32 -07:00
committed by Facebook GitHub Bot
parent d7e2e387f4
commit e67007c928
2 changed files with 9 additions and 3 deletions
@@ -564,6 +564,9 @@ void Binding::installFabricUIManager(
disableVirtualNodePreallocation_ = reactNativeConfig_->getBool(
"react_fabric:disable_virtual_node_preallocation");
enableEarlyEventEmitterUpdate_ = reactNativeConfig_->getBool(
"react_fabric:enable_early_event_emitter_update");
auto toolbox = SchedulerToolbox{};
toolbox.contextContainer = contextContainer;
toolbox.componentRegistryFactory = componentsRegistry->buildRegistryFunction;
@@ -1162,10 +1165,12 @@ void Binding::preallocateShadowView(
}
// Do not hold a reference to javaEventEmitter from the C++ side.
SharedEventEmitter eventEmitter = shadowView.eventEmitter;
auto javaEventEmitter = EventEmitterWrapper::newObjectJavaArgs();
EventEmitterWrapper *cEventEmitter = cthis(javaEventEmitter);
cEventEmitter->eventEmitter = eventEmitter;
if (enableEarlyEventEmitterUpdate_) {
SharedEventEmitter eventEmitter = shadowView.eventEmitter;
EventEmitterWrapper *cEventEmitter = cthis(javaEventEmitter);
cEventEmitter->eventEmitter = eventEmitter;
}
local_ref<ReadableMap::javaobject> props = castReadableMap(
ReadableNativeMap::newObjectCxxArgs(shadowView.props->rawProps));
@@ -194,6 +194,7 @@ class Binding : public jni::HybridClass<Binding>,
bool disablePreallocateViews_{false};
bool disableVirtualNodePreallocation_{false};
bool enableFabricLogs_{false};
bool enableEarlyEventEmitterUpdate_{false};
};
} // namespace react