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 9d9a1265de6..95ea4b0e50b 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 @@ -106,8 +106,11 @@ void Binding::startSurfaceWithConstraints( jboolean doLeftAndRightSwapInRTL) { SystraceSection s("FabricUIManagerBinding::startSurfaceWithConstraints"); - LOG(WARNING) << "Binding::startSurfaceWithConstraints() was called (address: " - << this << ", surfaceId: " << surfaceId << ")."; + if (enableFabricLogs_) { + LOG(WARNING) + << "Binding::startSurfaceWithConstraints() was called (address: " + << this << ", surfaceId: " << surfaceId << ")."; + } std::shared_ptr scheduler = getScheduler(); if (!scheduler) { @@ -155,8 +158,10 @@ void Binding::renderTemplateToSurface(jint surfaceId, jstring uiTemplate) { void Binding::stopSurface(jint surfaceId) { SystraceSection s("FabricUIManagerBinding::stopSurface"); - LOG(WARNING) << "Binding::stopSurface() was called (address: " << this - << ", surfaceId: " << surfaceId << ")."; + if (enableFabricLogs_) { + LOG(WARNING) << "Binding::stopSurface() was called (address: " << this + << ", surfaceId: " << surfaceId << ")."; + } std::shared_ptr scheduler = getScheduler(); if (!scheduler) { @@ -209,8 +214,16 @@ void Binding::installFabricUIManager( jni::alias_ref reactNativeConfig) { SystraceSection s("FabricUIManagerBinding::installFabricUIManager"); - LOG(WARNING) << "Binding::installFabricUIManager() was called (address: " - << this << ")."; + std::shared_ptr config = + std::make_shared(reactNativeConfig); + + enableFabricLogs_ = + config->getBool("react_fabric:enabled_android_fabric_logs"); + + if (enableFabricLogs_) { + LOG(WARNING) << "Binding::installFabricUIManager() was called (address: " + << this << ")."; + } // Use std::lock and std::adopt_lock to prevent deadlocks by locking mutexes // at the same time @@ -253,8 +266,6 @@ void Binding::installFabricUIManager( ownerBox, eventBeatManager, runtimeExecutor, localJavaUIManager); }; - std::shared_ptr config = - std::make_shared(reactNativeConfig); contextContainer->insert("ReactNativeConfig", config); contextContainer->insert("FabricUIManager", javaUIManager_); @@ -281,8 +292,10 @@ void Binding::installFabricUIManager( } void Binding::uninstallFabricUIManager() { - LOG(WARNING) << "Binding::uninstallFabricUIManager() was called (address: " - << this << ")."; + if (enableFabricLogs_) { + LOG(WARNING) << "Binding::uninstallFabricUIManager() was called (address: " + << this << ")."; + } // Use std::lock and std::adopt_lock to prevent deadlocks by locking mutexes // at the same time std::lock(schedulerMutex_, javaUIManagerMutex_); 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 2347ee5be0e..c5c216c39ab 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 @@ -112,6 +112,7 @@ class Binding : public jni::HybridClass, public SchedulerDelegate { bool collapseDeleteCreateMountingInstructions_{false}; bool disablePreallocateViews_{false}; bool disableVirtualNodePreallocation_{false}; + bool enableFabricLogs_{false}; }; } // namespace react