From be324ca2dc2705528e9599f75f84422613d406a9 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Thu, 21 Nov 2019 16:17:22 -0800 Subject: [PATCH] Fabric: Adding some logs to Scheduler, UIManager and co Summary: We hope that will help us to understand more. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D18599164 fbshipit-source-id: 431f83de707fc7113e04abd3dd5b59ee5c9cc675 --- .../java/com/facebook/react/fabric/jni/Binding.cpp | 11 +++++++++++ ReactCommon/fabric/uimanager/Scheduler.cpp | 3 +++ ReactCommon/fabric/uimanager/UIManager.cpp | 7 +++++++ ReactCommon/fabric/uimanager/UIManager.h | 1 + ReactCommon/fabric/uimanager/UIManagerBinding.cpp | 4 ++++ 5 files changed, 26 insertions(+) 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 5d40644d803..ed881126d22 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 @@ -102,6 +102,9 @@ void Binding::startSurfaceWithConstraints( jfloat maxHeight) { SystraceSection s("FabricUIManagerBinding::startSurfaceWithConstraints"); + LOG(WARNING) << "Binding::startSurfaceWithConstraints() was called (address: " + << this << ", surfaceId: " << surfaceId << ")."; + std::shared_ptr scheduler = getScheduler(); if (!scheduler) { LOG(ERROR) << "Binding::startSurfaceWithConstraints: scheduler disappeared"; @@ -145,6 +148,9 @@ 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 << ")."; + std::shared_ptr scheduler = getScheduler(); if (!scheduler) { LOG(ERROR) << "Binding::stopSurface: scheduler disappeared"; @@ -191,6 +197,9 @@ void Binding::installFabricUIManager( jni::alias_ref reactNativeConfig) { SystraceSection s("FabricUIManagerBinding::installFabricUIManager"); + 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 std::lock(schedulerMutex_, javaUIManagerMutex_); std::lock_guard schedulerLock(schedulerMutex_, std::adopt_lock); @@ -252,6 +261,8 @@ void Binding::installFabricUIManager( } void Binding::uninstallFabricUIManager() { + 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_); std::lock_guard schedulerLock(schedulerMutex_, std::adopt_lock); diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index d81a7a253a5..25b4b9e1724 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -85,6 +85,9 @@ Scheduler::Scheduler( } Scheduler::~Scheduler() { + LOG(WARNING) << "Scheduler::~Scheduler() was called (address: " << this + << ")."; + // All Surfaces must be explicitly stopped before destroying `Scheduler`. // The idea is that `UIManager` is allowed to call `Scheduler` only if the // corresponding `ShadowTree` instance exists. diff --git a/ReactCommon/fabric/uimanager/UIManager.cpp b/ReactCommon/fabric/uimanager/UIManager.cpp index dbd03c72bad..0f5c7efb15a 100644 --- a/ReactCommon/fabric/uimanager/UIManager.cpp +++ b/ReactCommon/fabric/uimanager/UIManager.cpp @@ -10,9 +10,16 @@ #include #include +#include + namespace facebook { namespace react { +UIManager::~UIManager() { + LOG(WARNING) << "UIManager::~UIManager() was called (address: " << this + << ")."; +} + SharedShadowNode UIManager::createNode( Tag tag, std::string const &name, diff --git a/ReactCommon/fabric/uimanager/UIManager.h b/ReactCommon/fabric/uimanager/UIManager.h index b0ed2e6339d..3064eec8fca 100644 --- a/ReactCommon/fabric/uimanager/UIManager.h +++ b/ReactCommon/fabric/uimanager/UIManager.h @@ -26,6 +26,7 @@ class UIManagerBinding; class UIManager final : public ShadowTreeDelegate { public: + ~UIManager(); void setComponentDescriptorRegistry( const SharedComponentDescriptorRegistry &componentDescriptorRegistry); diff --git a/ReactCommon/fabric/uimanager/UIManagerBinding.cpp b/ReactCommon/fabric/uimanager/UIManagerBinding.cpp index 15f5da97724..7aa6156ee05 100644 --- a/ReactCommon/fabric/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/fabric/uimanager/UIManagerBinding.cpp @@ -9,6 +9,7 @@ #include +#include #include namespace facebook { @@ -53,6 +54,9 @@ std::shared_ptr UIManagerBinding::createAndInstallIfNeeded( } UIManagerBinding::~UIManagerBinding() { + LOG(WARNING) << "UIManager::~UIManager() was called (address: " << this + << ")."; + // We must detach the `UIBinding` on deallocation to prevent accessing // deallocated `UIManagerBinding`. // Since `UIManagerBinding` retains `UIManager`, `UIManager` always overlive