From e67007c928e52679e149ad0229059197369763c0 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 14 Jun 2021 19:29:54 -0700 Subject: [PATCH] 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 --- .../java/com/facebook/react/fabric/jni/Binding.cpp | 11 ++++++++--- .../main/java/com/facebook/react/fabric/jni/Binding.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index d5fd9ca7fab..9b6215596cf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -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 props = castReadableMap( ReadableNativeMap::newObjectCxxArgs(shadowView.props->rawProps)); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index 79b38d9bb2e..033e57700a3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -194,6 +194,7 @@ class Binding : public jni::HybridClass, bool disablePreallocateViews_{false}; bool disableVirtualNodePreallocation_{false}; bool enableFabricLogs_{false}; + bool enableEarlyEventEmitterUpdate_{false}; }; } // namespace react