From 88773c64f6fb0c8dc6053805476e96ef40f58e7f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 19 Dec 2024 02:28:14 -0800 Subject: [PATCH] Remove getInspectorDataForInstance Summary: This API was never adopted or implemented on iOS, and is not compatible with bridgeless. Changelog: [Internal] Differential Revision: D67342500 --- .../ReactAndroid/api/ReactAndroid.api | 1 - .../react/fabric/FabricUIManager.java | 23 -------------- .../react/fabric/FabricUIManagerBinding.kt | 6 ---- .../react/fabric/FabricUIManagerBinding.cpp | 30 ------------------ .../jni/react/fabric/FabricUIManagerBinding.h | 3 -- .../react/renderer/scheduler/Scheduler.cpp | 31 ------------------- .../react/renderer/scheduler/Scheduler.h | 3 -- .../renderer/uimanager/UIManagerBinding.cpp | 27 ---------------- .../renderer/uimanager/UIManagerBinding.h | 4 --- 9 files changed, 128 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 4adddfaa84a0f5..1c2b172ffdfc4c 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2595,7 +2595,6 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid public fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V public fun getColor (I[Ljava/lang/String;)I public fun getEventDispatcher ()Lcom/facebook/react/uimanager/events/EventDispatcher; - public fun getInspectorDataForInstance (ILandroid/view/View;)Lcom/facebook/react/bridge/ReadableMap; public fun getPerformanceCounters ()Ljava/util/Map; public fun getThemeData (I[F)Z public fun initialize ()V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 4085705499cae7..803b9441e347e1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -257,29 +257,6 @@ public int addRootView(final T rootView, final WritableMap init return rootTag; } - /** - * This API returns metadata associated to the React Component that rendered the Android View - * received as a parameter. - * - * @param surfaceId {@link int} that represents the surfaceId for the View received as a - * parameter. In practice surfaceId can be retrieved calling the {@link View#getId()} method - * on the {@link ReactRoot} that holds the View received as a second parameter. - * @param view {@link View} view that will be used to retrieve the React view hierarchy metadata. - * @return a {@link ReadableMap} that contains metadata associated to the React Component that - * rendered the Android View received as a parameter. For more details about the keys stored - * in the {@link ReadableMap} refer to the "getInspectorDataForInstance" method from - * jni/react/fabric/Binding.cpp file. - */ - @UiThread - @ThreadConfined(UI) - public ReadableMap getInspectorDataForInstance(final int surfaceId, final View view) { - UiThreadUtil.assertOnUiThread(); - int reactTag = view.getId(); - - EventEmitterWrapper eventEmitter = mMountingManager.getEventEmitter(surfaceId, reactTag); - return mBinding.getInspectorDataForInstance(eventEmitter); - } - @Override @AnyThread @ThreadConfined(ANY) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerBinding.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerBinding.kt index 1607d1bda33a66..38ce98527e3995 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerBinding.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerBinding.kt @@ -11,12 +11,10 @@ import android.annotation.SuppressLint import com.facebook.jni.HybridClassBase import com.facebook.proguard.annotations.DoNotStrip import com.facebook.react.bridge.NativeMap -import com.facebook.react.bridge.ReadableNativeMap import com.facebook.react.bridge.RuntimeExecutor import com.facebook.react.bridge.RuntimeScheduler import com.facebook.react.common.mapbuffer.MapBufferSoLoader import com.facebook.react.fabric.events.EventBeatManager -import com.facebook.react.fabric.events.EventEmitterWrapper import com.facebook.react.uimanager.PixelUtil.getDisplayMetricDensity @DoNotStrip @@ -82,10 +80,6 @@ internal class FabricUIManagerBinding : HybridClassBase() { public external fun reportMount(surfaceId: Int) - public external fun getInspectorDataForInstance( - eventEmitterWrapper: EventEmitterWrapper? - ): ReadableNativeMap? - public fun register( runtimeExecutor: RuntimeExecutor, runtimeScheduler: RuntimeScheduler, diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp index 1c356ca9fc00dd..dc20fc75b6022a 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp @@ -44,33 +44,6 @@ std::shared_ptr FabricUIManagerBinding::getScheduler() { return scheduler_; } -jni::local_ref -FabricUIManagerBinding::getInspectorDataForInstance( - jni::alias_ref eventEmitterWrapper) { - auto scheduler = getScheduler(); - if (!scheduler) { - LOG(ERROR) << "FabricUIManagerBinding::startSurface: scheduler disappeared"; - return ReadableNativeMap::newObjectCxxArgs(folly::dynamic::object()); - } - - EventEmitterWrapper* cEventEmitter = cthis(eventEmitterWrapper); - InspectorData data = - scheduler->getInspectorDataForInstance(*cEventEmitter->eventEmitter); - - folly::dynamic result = folly::dynamic::object; - result["fileName"] = data.fileName; - result["lineNumber"] = data.lineNumber; - result["columnNumber"] = data.columnNumber; - result["selectedIndex"] = data.selectedIndex; - result["props"] = data.props; - auto hierarchy = folly::dynamic::array(); - for (const auto& hierarchyItem : data.hierarchy) { - hierarchy.push_back(hierarchyItem); - } - result["hierarchy"] = hierarchy; - return ReadableNativeMap::newObjectCxxArgs(result); -} - void FabricUIManagerBinding::setPixelDensity(float pointScaleFactor) { pointScaleFactor_ = pointScaleFactor; } @@ -661,9 +634,6 @@ void FabricUIManagerBinding::registerNatives() { "installFabricUIManager", FabricUIManagerBinding::installFabricUIManager), makeNativeMethod("startSurface", FabricUIManagerBinding::startSurface), - makeNativeMethod( - "getInspectorDataForInstance", - FabricUIManagerBinding::getInspectorDataForInstance), makeNativeMethod( "startSurfaceWithConstraints", FabricUIManagerBinding::startSurfaceWithConstraints), diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.h b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.h index 2976dc721923bc..50c234eca5f539 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.h @@ -57,9 +57,6 @@ class FabricUIManagerBinding : public jni::HybridClass, jboolean isRTL, jboolean doLeftAndRightSwapInRTL); - jni::local_ref getInspectorDataForInstance( - jni::alias_ref eventEmitterWrapper); - static void initHybrid(jni::alias_ref jobj); void installFabricUIManager( diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 01c5af176037a3..0261abc1a34784 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -216,37 +216,6 @@ void Scheduler::registerSurface( surfaceHandler.setUIManager(uiManager_.get()); } -InspectorData Scheduler::getInspectorDataForInstance( - const EventEmitter& eventEmitter) const noexcept { - return executeSynchronouslyOnSameThread_CAN_DEADLOCK( - runtimeExecutor_, [=](jsi::Runtime& runtime) -> InspectorData { - auto uiManagerBinding = UIManagerBinding::getBinding(runtime); - auto value = uiManagerBinding->getInspectorDataForInstance( - runtime, eventEmitter); - - // TODO T97216348: avoid transforming jsi into folly::dynamic - auto dynamic = jsi::dynamicFromValue(runtime, value); - auto source = dynamic["source"]; - - InspectorData result = {}; - result.fileName = - source["fileName"].isNull() ? "" : source["fileName"].c_str(); - result.lineNumber = (int)source["lineNumber"].getDouble(); - result.columnNumber = (int)source["columnNumber"].getDouble(); - result.selectedIndex = (int)dynamic["selectedIndex"].getDouble(); - // TODO T97216348: remove folly::dynamic from InspectorData struct - result.props = dynamic["props"]; - auto hierarchy = dynamic["hierarchy"]; - for (auto& i : hierarchy) { - auto viewHierarchyValue = i["name"]; - if (!viewHierarchyValue.isNull()) { - result.hierarchy.emplace_back(viewHierarchyValue.c_str()); - } - } - return result; - }); -} - void Scheduler::unregisterSurface( const SurfaceHandler& surfaceHandler) const noexcept { surfaceHandler.setUIManager(nullptr); diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h index 30ab071b92f53b..4e364dbe6fcecb 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -52,9 +52,6 @@ class Scheduler final : public UIManagerDelegate { void registerSurface(const SurfaceHandler& surfaceHandler) const noexcept; void unregisterSurface(const SurfaceHandler& surfaceHandler) const noexcept; - InspectorData getInspectorDataForInstance( - const EventEmitter& eventEmitter) const noexcept; - /* * This is broken. Please do not use. * `ComponentDescriptor`s are not designed to be used outside of `UIManager`, diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index a9a97a53dbc2f4..de7ec91b18bc7d 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -62,33 +62,6 @@ UIManagerBinding::~UIManagerBinding() { << this << ")."; } -jsi::Value UIManagerBinding::getInspectorDataForInstance( - jsi::Runtime& runtime, - const EventEmitter& eventEmitter) const { - auto eventTarget = eventEmitter.eventTarget_; - EventEmitter::DispatchMutex().lock(); - - if (!runtime.global().hasProperty(runtime, "__fbBatchedBridge") || - !eventTarget) { - return jsi::Value::undefined(); - } - - eventTarget->retain(runtime); - auto instanceHandle = eventTarget->getInstanceHandle(runtime); - eventTarget->release(runtime); - EventEmitter::DispatchMutex().unlock(); - - if (instanceHandle.isUndefined()) { - return jsi::Value::undefined(); - } - - return callMethodOfModule( - runtime, - "ReactFabric", - "getInspectorDataForInstance", - {std::move(instanceHandle)}); -} - void UIManagerBinding::dispatchEvent( jsi::Runtime& runtime, const EventTarget* eventTarget, diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.h b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.h index 8f8e6a387898ee..ef6c682df00292 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.h @@ -40,10 +40,6 @@ class UIManagerBinding : public jsi::HostObject { ~UIManagerBinding() override; - jsi::Value getInspectorDataForInstance( - jsi::Runtime& runtime, - const EventEmitter& eventEmitter) const; - /* * Delivers raw event data to JavaScript. * Thread synchronization must be enforced externally.