mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Remove unused NotThreadSafeBridgeIdleDebugListener (#54559)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54559 This class is no longer used. It's a legacy arch class used to populate the legacy FPS counter. We can safely remove it now because we're on NewArch only. Marking this as breaking because I removed some methods from some public classes. Changelog: [Android] [Breaking] - Remove unused internal `NotThreadSafeBridgeIdleDebugListener` Reviewed By: mdvacca Differential Revision: D87220846 fbshipit-source-id: 8b0ed0f8895d6768411e0674cf52d16fa9491604
This commit is contained in:
1 parent
991dff2322
commit
0ee4a2d01a
9 files changed
+3
-309
No files matched your search
@@ -296,7 +296,6 @@ public final class com/facebook/react/ReactInstanceManagerBuilder {
|
||||
public final fun addPackages (Ljava/util/List;)Lcom/facebook/react/ReactInstanceManagerBuilder;
|
||||
public final fun build ()Lcom/facebook/react/ReactInstanceManager;
|
||||
public final fun setApplication (Landroid/app/Application;)Lcom/facebook/react/ReactInstanceManagerBuilder;
|
||||
public final fun setBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)Lcom/facebook/react/ReactInstanceManagerBuilder;
|
||||
public final fun setBundleAssetName (Ljava/lang/String;)Lcom/facebook/react/ReactInstanceManagerBuilder;
|
||||
public final fun setChoreographerProvider (Lcom/facebook/react/internal/ChoreographerProvider;)Lcom/facebook/react/ReactInstanceManagerBuilder;
|
||||
public final fun setCurrentActivity (Landroid/app/Activity;)Lcom/facebook/react/ReactInstanceManagerBuilder;
|
||||
@@ -583,7 +582,6 @@ public abstract interface class com/facebook/react/bridge/Callback {
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/bridge/CatalystInstance : com/facebook/react/bridge/JSBundleLoaderDelegate, com/facebook/react/bridge/JSInstance, com/facebook/react/bridge/MemoryPressureListener {
|
||||
public abstract fun addBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
|
||||
public abstract fun callFunction (Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/NativeArray;)V
|
||||
public abstract fun destroy ()V
|
||||
public abstract fun extendNativeModules (Lcom/facebook/react/bridge/NativeModuleRegistry;)V
|
||||
@@ -605,7 +603,6 @@ public abstract interface class com/facebook/react/bridge/CatalystInstance : com
|
||||
public abstract fun invokeCallback (ILcom/facebook/react/bridge/NativeArrayInterface;)V
|
||||
public abstract fun isDestroyed ()Z
|
||||
public abstract fun registerSegment (ILjava/lang/String;)V
|
||||
public abstract fun removeBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
|
||||
public abstract fun runJSBundle ()V
|
||||
public abstract fun setFabricUIManager (Lcom/facebook/react/bridge/UIManager;)V
|
||||
public abstract fun setGlobalVariable (Ljava/lang/String;Ljava/lang/String;)V
|
||||
@@ -613,7 +610,6 @@ public abstract interface class com/facebook/react/bridge/CatalystInstance : com
|
||||
}
|
||||
|
||||
public class com/facebook/react/bridge/CatalystInstanceImpl : com/facebook/react/bridge/CatalystInstance {
|
||||
public fun addBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
|
||||
public fun callFunction (Lcom/facebook/react/bridge/CatalystInstanceImpl$PendingJSCall;)V
|
||||
public fun callFunction (Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/NativeArray;)V
|
||||
public fun destroy ()V
|
||||
@@ -641,7 +637,6 @@ public class com/facebook/react/bridge/CatalystInstanceImpl : com/facebook/react
|
||||
public fun loadScriptFromFile (Ljava/lang/String;Ljava/lang/String;Z)V
|
||||
public fun loadSplitBundleFromFile (Ljava/lang/String;Ljava/lang/String;)V
|
||||
public fun registerSegment (ILjava/lang/String;)V
|
||||
public fun removeBridgeIdleDebugListener (Lcom/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener;)V
|
||||
public fun runJSBundle ()V
|
||||
public fun setFabricUIManager (Lcom/facebook/react/bridge/UIManager;)V
|
||||
public fun setGlobalVariable (Ljava/lang/String;Ljava/lang/String;)V
|
||||
@@ -970,12 +965,6 @@ public final class com/facebook/react/bridge/NoSuchKeyException : java/lang/Runt
|
||||
public fun <init> (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener {
|
||||
public abstract fun onBridgeDestroyed ()V
|
||||
public abstract fun onTransitionToBridgeBusy ()V
|
||||
public abstract fun onTransitionToBridgeIdle ()V
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/bridge/PerformanceCounter {
|
||||
public abstract fun getPerformanceCounters ()Ljava/util/Map;
|
||||
public abstract fun profileNextBatch ()V
|
||||
|
||||
-7
@@ -57,7 +57,6 @@ import com.facebook.react.bridge.JSExceptionHandler;
|
||||
import com.facebook.react.bridge.JavaScriptExecutor;
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
||||
import com.facebook.react.bridge.NativeModuleRegistry;
|
||||
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactCxxErrorHandler;
|
||||
@@ -183,7 +182,6 @@ public class ReactInstanceManager {
|
||||
private final boolean mUseDeveloperSupport;
|
||||
private final boolean mRequireActivity;
|
||||
private final boolean mKeepActivity;
|
||||
private final @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
|
||||
private final Object mReactContextLock = new Object();
|
||||
private @Nullable volatile ReactContext mCurrentReactContext;
|
||||
private final Context mApplicationContext;
|
||||
@@ -246,7 +244,6 @@ public class ReactInstanceManager {
|
||||
DevSupportManagerFactory devSupportManagerFactory,
|
||||
boolean requireActivity,
|
||||
boolean keepActivity,
|
||||
@Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
|
||||
LifecycleState initialLifecycleState,
|
||||
JSExceptionHandler jSExceptionHandler,
|
||||
@Nullable RedBoxHandler redBoxHandler,
|
||||
@@ -292,7 +289,6 @@ public class ReactInstanceManager {
|
||||
devLoadingViewManager,
|
||||
pausedInDebuggerOverlayManager);
|
||||
Systrace.endSection(TRACE_TAG_REACT);
|
||||
mBridgeIdleDebugListener = bridgeIdleDebugListener;
|
||||
mLifecycleState = initialLifecycleState;
|
||||
mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
|
||||
mJSExceptionHandler = jSExceptionHandler;
|
||||
@@ -1517,9 +1513,6 @@ public class ReactInstanceManager {
|
||||
catalystInstance.setFabricUIManager(uiManager);
|
||||
}
|
||||
}
|
||||
if (mBridgeIdleDebugListener != null) {
|
||||
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
|
||||
}
|
||||
if (BuildConfig.ENABLE_PERFETTO || Systrace.isTracing(TRACE_TAG_REACT)) {
|
||||
catalystInstance.setGlobalVariable("__RCTProfileIsProfiling", "true");
|
||||
}
|
||||
|
||||
-10
@@ -19,7 +19,6 @@ import com.facebook.react.ReactInstanceManager.initializeSoLoaderIfNecessary
|
||||
import com.facebook.react.bridge.JSBundleLoader
|
||||
import com.facebook.react.bridge.JSExceptionHandler
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory
|
||||
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener
|
||||
import com.facebook.react.bridge.UIManagerProvider
|
||||
import com.facebook.react.common.LifecycleState
|
||||
import com.facebook.react.common.SurfaceDelegateFactory
|
||||
@@ -49,7 +48,6 @@ public class ReactInstanceManagerBuilder {
|
||||
private var jsBundleAssetUrl: String? = null
|
||||
private var jsBundleLoader: JSBundleLoader? = null
|
||||
private var jsMainModulePath: String? = null
|
||||
private var bridgeIdleDebugListener: NotThreadSafeBridgeIdleDebugListener? = null
|
||||
private var application: Application? = null
|
||||
private var useDeveloperSupport = false
|
||||
private var devSupportManagerFactory: DevSupportManagerFactory? = null
|
||||
@@ -145,13 +143,6 @@ public class ReactInstanceManagerBuilder {
|
||||
return this
|
||||
}
|
||||
|
||||
public fun setBridgeIdleDebugListener(
|
||||
bridgeIdleDebugListener: NotThreadSafeBridgeIdleDebugListener
|
||||
): ReactInstanceManagerBuilder {
|
||||
this.bridgeIdleDebugListener = bridgeIdleDebugListener
|
||||
return this
|
||||
}
|
||||
|
||||
/** Required. This must be your `Application` instance. */
|
||||
public fun setApplication(application: Application): ReactInstanceManagerBuilder {
|
||||
this.application = application
|
||||
@@ -359,7 +350,6 @@ public class ReactInstanceManagerBuilder {
|
||||
devSupportManagerFactory ?: DefaultDevSupportManagerFactory(),
|
||||
requireActivity,
|
||||
keepActivity,
|
||||
bridgeIdleDebugListener,
|
||||
checkNotNull(initialLifecycleState) { "Initial lifecycle state was not set" },
|
||||
jsExceptionHandler,
|
||||
redBoxHandler,
|
||||
|
||||
-18
@@ -75,24 +75,6 @@ public interface CatalystInstance : MemoryPressureListener, JSInstance, JSBundle
|
||||
*/
|
||||
public fun extendNativeModules(modules: NativeModuleRegistry)
|
||||
|
||||
/**
|
||||
* Adds a idle listener for this Catalyst instance. The listener will receive notifications
|
||||
* whenever the bridge transitions from idle to busy and vice-versa, where the busy state is
|
||||
* defined as there being some non-zero number of calls to JS that haven't resolved via a
|
||||
* onBatchCompleted call. The listener should be purely passive and not affect application logic.
|
||||
*/
|
||||
public fun addBridgeIdleDebugListener(
|
||||
@Suppress("DEPRECATION") listener: NotThreadSafeBridgeIdleDebugListener
|
||||
)
|
||||
|
||||
/**
|
||||
* Removes a NotThreadSafeBridgeIdleDebugListener previously added with
|
||||
* [addBridgeIdleDebugListener]
|
||||
*/
|
||||
public fun removeBridgeIdleDebugListener(
|
||||
@Suppress("DEPRECATION") listener: NotThreadSafeBridgeIdleDebugListener
|
||||
)
|
||||
|
||||
/** This method registers the file path of an additional JS segment by its ID. */
|
||||
public fun registerSegment(segmentId: Int, path: String)
|
||||
|
||||
|
||||
-54
@@ -39,7 +39,6 @@ import com.facebook.systrace.TraceListener;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@@ -88,7 +87,6 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
// Access from any thread
|
||||
private final ReactQueueConfigurationImpl mReactQueueConfiguration;
|
||||
private final CopyOnWriteArrayList<NotThreadSafeBridgeIdleDebugListener> mBridgeIdleListeners;
|
||||
private final AtomicInteger mPendingJSCalls = new AtomicInteger(0);
|
||||
private final String mJsPendingCallsTitleForTrace =
|
||||
"pending_js_calls_instance" + sNextInstanceIdForTrace.getAndIncrement();
|
||||
@@ -138,7 +136,6 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
mReactQueueConfiguration =
|
||||
ReactQueueConfigurationImpl.create(
|
||||
reactQueueConfigurationSpec, new NativeExceptionHandler());
|
||||
mBridgeIdleListeners = new CopyOnWriteArrayList<>();
|
||||
mNativeModuleRegistry = nativeModuleRegistry;
|
||||
mJSModuleRegistry = new JavaScriptModuleRegistry();
|
||||
mJSBundleLoader = jsBundleLoader;
|
||||
@@ -372,14 +369,6 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
mFabricUIManager.invalidate();
|
||||
}
|
||||
boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0);
|
||||
if (!mBridgeIdleListeners.isEmpty()) {
|
||||
for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
|
||||
if (!wasIdle) {
|
||||
listener.onTransitionToBridgeIdle();
|
||||
}
|
||||
listener.onBridgeDestroyed();
|
||||
}
|
||||
}
|
||||
|
||||
getReactQueueConfiguration()
|
||||
.getJSQueueThread()
|
||||
@@ -521,30 +510,6 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
jniHandleMemoryPressure(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a idle listener for this Catalyst instance. The listener will receive notifications
|
||||
* whenever the bridge transitions from idle to busy and vice-versa, where the busy state is
|
||||
* defined as there being some non-zero number of calls to JS that haven't resolved via a
|
||||
* onBatchComplete call. The listener should be purely passive and not affect application logic.
|
||||
*
|
||||
* @noinspection deprecation
|
||||
*/
|
||||
@Override
|
||||
public void addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
|
||||
mBridgeIdleListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a NotThreadSafeBridgeIdleDebugListener previously added with {@link
|
||||
* #addBridgeIdleDebugListener}
|
||||
*
|
||||
* @noinspection deprecation
|
||||
*/
|
||||
@Override
|
||||
public void removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
|
||||
mBridgeIdleListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void setGlobalVariable(String propName, String jsonValue);
|
||||
|
||||
@@ -561,16 +526,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
private void incrementPendingJSCalls() {
|
||||
int oldPendingCalls = mPendingJSCalls.getAndIncrement();
|
||||
boolean wasIdle = oldPendingCalls == 0;
|
||||
Systrace.traceCounter(TRACE_TAG_REACT, mJsPendingCallsTitleForTrace, oldPendingCalls + 1);
|
||||
if (wasIdle && !mBridgeIdleListeners.isEmpty()) {
|
||||
mNativeModulesQueueThread.runOnQueue(
|
||||
() -> {
|
||||
for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
|
||||
listener.onTransitionToBridgeBusy();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -592,17 +548,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
int newPendingCalls = mPendingJSCalls.decrementAndGet();
|
||||
// TODO(9604406): handle case of web workers injecting messages to main thread
|
||||
// Assertions.assertCondition(newPendingCalls >= 0);
|
||||
boolean isNowIdle = newPendingCalls == 0;
|
||||
Systrace.traceCounter(TRACE_TAG_REACT, mJsPendingCallsTitleForTrace, newPendingCalls);
|
||||
|
||||
if (isNowIdle && !mBridgeIdleListeners.isEmpty()) {
|
||||
mNativeModulesQueueThread.runOnQueue(
|
||||
() -> {
|
||||
for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
|
||||
listener.onTransitionToBridgeIdle();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void onNativeException(Exception e) {
|
||||
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge
|
||||
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitecture
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
|
||||
|
||||
/**
|
||||
* Interface for receiving notification for bridge idle/busy events. Should not affect application
|
||||
* logic and should only be used for debug/monitoring/testing purposes. Call
|
||||
* [ ][CatalystInstance.addBridgeIdleDebugListener] to start monitoring.
|
||||
*
|
||||
* NB: onTransitionToBridgeIdle and onTransitionToBridgeBusy may be called from different threads,
|
||||
* and those threads may not be the same thread on which the listener was originally registered.
|
||||
*/
|
||||
@Deprecated("NotThreadSafeBridgeIdleDebugListener will be deleted in the new architecture.")
|
||||
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
|
||||
public interface NotThreadSafeBridgeIdleDebugListener {
|
||||
/**
|
||||
* Called once all pending JS calls have resolved via an onBatchComplete call in the bridge and
|
||||
* the requested native module calls have also run. The bridge will not become busy again until a
|
||||
* timer, touch event, etc. causes a Java->JS call to be enqueued again.
|
||||
*/
|
||||
public fun onTransitionToBridgeIdle()
|
||||
|
||||
/** Called when the bridge was in an idle state and executes a JS call or callback. */
|
||||
public fun onTransitionToBridgeBusy()
|
||||
|
||||
/** Called when the bridge is destroyed */
|
||||
public fun onBridgeDestroyed()
|
||||
}
|
||||
-145
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
@file:Suppress(
|
||||
"DEPRECATION"
|
||||
) // Suppressing deprecation of NotThreadSafeViewHierarchyUpdateDebugListener
|
||||
|
||||
package com.facebook.react.modules.debug
|
||||
|
||||
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener
|
||||
|
||||
/**
|
||||
* Debug object that listens to bridge busy/idle events and UiManagerModule dispatches and uses it
|
||||
* to calculate whether JS was able to update the UI during a given frame. After being installed on
|
||||
* a [ReactBridge] and a [com.facebook.react.uimanager.UIManagerModule],
|
||||
* [getDidJSHitFrameAndCleanup] should be called once per frame via a
|
||||
* [android.view.Choreographer.FrameCallback].
|
||||
*/
|
||||
internal class DidJSUpdateUiDuringFrameDetector : NotThreadSafeBridgeIdleDebugListener {
|
||||
private val transitionToIdleEvents = ArrayList<Long>(20)
|
||||
private val transitionToBusyEvents = ArrayList<Long>(20)
|
||||
private val viewHierarchyUpdateEnqueuedEvents = ArrayList<Long>(20)
|
||||
private val viewHierarchyUpdateFinishedEvents = ArrayList<Long>(20)
|
||||
@Volatile private var wasIdleAtEndOfLastFrame = true
|
||||
|
||||
@Synchronized
|
||||
override fun onTransitionToBridgeIdle() {
|
||||
transitionToIdleEvents.add(System.nanoTime())
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onTransitionToBridgeBusy() {
|
||||
transitionToBusyEvents.add(System.nanoTime())
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onBridgeDestroyed() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Designed to be called from a [android.view.Choreographer.FrameCallback.doFrame] call.
|
||||
*
|
||||
* There are two 'success' cases that will cause [getDidJSHitFrameAndCleanup] to return true for a
|
||||
* given frame:
|
||||
* 1. UIManagerModule finished dispatching a batched UI update on the UI thread during the frame.
|
||||
* This means that during the next hierarchy traversal, new UI will be drawn if needed (good).
|
||||
* 1. The bridge ended the frame idle (meaning there were no JS nor native module calls still in
|
||||
* flight) AND there was no UiManagerModule update enqueued that didn't also finish. NB: if
|
||||
* there was one enqueued that actually finished, we'd have case 1), so effectively we just
|
||||
* look for whether one was enqueued.
|
||||
*
|
||||
* NB: This call can only be called once for a given frame time range because it cleans up events
|
||||
* it recorded for that frame.
|
||||
*
|
||||
* NB2: This makes the assumption that [onViewHierarchyUpdateEnqueued] is called from the
|
||||
* [com.facebook.react.uimanager.UIManagerModule.onBatchComplete], e.g. while the bridge is still
|
||||
* considered busy, which means there is no race condition where the bridge has gone idle but a
|
||||
* hierarchy update is waiting to be enqueued.
|
||||
*
|
||||
* @param frameStartTimeNanos the time in nanos that the last frame started
|
||||
* @param frameEndTimeNanos the time in nanos that the last frame ended
|
||||
*/
|
||||
@Synchronized
|
||||
fun getDidJSHitFrameAndCleanup(frameStartTimeNanos: Long, frameEndTimeNanos: Long): Boolean {
|
||||
// Case 1: We dispatched a UI update
|
||||
val finishedUiUpdate =
|
||||
hasEventBetweenTimestamps(
|
||||
viewHierarchyUpdateFinishedEvents,
|
||||
frameStartTimeNanos,
|
||||
frameEndTimeNanos,
|
||||
)
|
||||
val didEndFrameIdle = didEndFrameIdle(frameStartTimeNanos, frameEndTimeNanos)
|
||||
val hitFrame =
|
||||
if (finishedUiUpdate) {
|
||||
true
|
||||
} else {
|
||||
// Case 2: Ended idle but no UI was enqueued during that frame
|
||||
(didEndFrameIdle &&
|
||||
!hasEventBetweenTimestamps(
|
||||
viewHierarchyUpdateEnqueuedEvents,
|
||||
frameStartTimeNanos,
|
||||
frameEndTimeNanos,
|
||||
))
|
||||
}
|
||||
cleanUp(transitionToIdleEvents, frameEndTimeNanos)
|
||||
cleanUp(transitionToBusyEvents, frameEndTimeNanos)
|
||||
cleanUp(viewHierarchyUpdateEnqueuedEvents, frameEndTimeNanos)
|
||||
cleanUp(viewHierarchyUpdateFinishedEvents, frameEndTimeNanos)
|
||||
wasIdleAtEndOfLastFrame = didEndFrameIdle
|
||||
return hitFrame
|
||||
}
|
||||
|
||||
private fun didEndFrameIdle(startTime: Long, endTime: Long): Boolean {
|
||||
val lastIdleTransition =
|
||||
getLastEventBetweenTimestamps(transitionToIdleEvents, startTime, endTime)
|
||||
val lastBusyTransition =
|
||||
getLastEventBetweenTimestamps(transitionToBusyEvents, startTime, endTime)
|
||||
return if (lastIdleTransition == -1L && lastBusyTransition == -1L) {
|
||||
wasIdleAtEndOfLastFrame
|
||||
} else lastIdleTransition > lastBusyTransition
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasEventBetweenTimestamps(
|
||||
eventArray: ArrayList<Long>,
|
||||
startTime: Long,
|
||||
endTime: Long,
|
||||
): Boolean = eventArray.any { time -> time in startTime until endTime }
|
||||
|
||||
private fun getLastEventBetweenTimestamps(
|
||||
eventArray: ArrayList<Long>,
|
||||
startTime: Long,
|
||||
endTime: Long,
|
||||
): Long {
|
||||
var lastEvent: Long = -1
|
||||
for (time in eventArray) {
|
||||
if (time in startTime until endTime) {
|
||||
lastEvent = time
|
||||
} else if (time >= endTime) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return lastEvent
|
||||
}
|
||||
|
||||
private fun cleanUp(eventArray: ArrayList<Long>, endTime: Long) {
|
||||
val size = eventArray.size
|
||||
var indicesToRemove = 0
|
||||
for (i in 0 until size) {
|
||||
if (eventArray[i] < endTime) {
|
||||
indicesToRemove++
|
||||
}
|
||||
}
|
||||
if (indicesToRemove > 0) {
|
||||
for (i in 0 until size - indicesToRemove) {
|
||||
eventArray[i] = eventArray[i + indicesToRemove]
|
||||
}
|
||||
eventArray.dropLast(indicesToRemove)
|
||||
}
|
||||
}
|
||||
+3
-19
@@ -26,8 +26,6 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) :
|
||||
Choreographer.FrameCallback {
|
||||
|
||||
private var choreographer: Choreographer? = null
|
||||
private val didJSUpdateUiDuringFrameDetector: DidJSUpdateUiDuringFrameDetector =
|
||||
DidJSUpdateUiDuringFrameDetector()
|
||||
private var firstFrameTime: Long = -1
|
||||
private var lastFrameTime: Long = -1
|
||||
private var numFrameCallbacks = 0
|
||||
@@ -40,11 +38,7 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) :
|
||||
if (firstFrameTime == -1L) {
|
||||
firstFrameTime = l
|
||||
}
|
||||
val lastFrameStartTime = lastFrameTime
|
||||
lastFrameTime = l
|
||||
if (didJSUpdateUiDuringFrameDetector.getDidJSHitFrameAndCleanup(lastFrameStartTime, l)) {
|
||||
numFrameCallbacksWithBatchDispatches++
|
||||
}
|
||||
numFrameCallbacks++
|
||||
val expectedNumFrames = expectedNumFrames
|
||||
val framesDropped = expectedNumFrames - expectedNumFramesPrev - 1
|
||||
@@ -61,14 +55,9 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) :
|
||||
// removeBridgeIdleDebugListener for Bridgeless
|
||||
@Suppress("DEPRECATION")
|
||||
if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
|
||||
if (!reactContext.isBridgeless) {
|
||||
reactContext.catalystInstance.addBridgeIdleDebugListener(didJSUpdateUiDuringFrameDetector)
|
||||
isRunningOnFabric = false
|
||||
} else {
|
||||
// T172641976 Consider either implementing a mechanism similar to addBridgeIdleDebugListener
|
||||
// for Fabric or point users to use RNDT.
|
||||
isRunningOnFabric = true
|
||||
}
|
||||
// T172641976 Consider either implementing a mechanism similar to addBridgeIdleDebugListener
|
||||
// for Fabric or point users to use RNDT.
|
||||
isRunningOnFabric = true
|
||||
}
|
||||
this.targetFps = targetFps
|
||||
UiThreadUtil.runOnUiThread {
|
||||
@@ -79,11 +68,6 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) :
|
||||
|
||||
fun stop() {
|
||||
@Suppress("DEPRECATION")
|
||||
if (
|
||||
!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE && !reactContext.isBridgeless
|
||||
) {
|
||||
reactContext.catalystInstance.removeBridgeIdleDebugListener(didJSUpdateUiDuringFrameDetector)
|
||||
}
|
||||
UiThreadUtil.runOnUiThread {
|
||||
choreographer = Choreographer.getInstance()
|
||||
choreographer?.removeFrameCallback(this)
|
||||
|
||||
-9
@@ -19,7 +19,6 @@ import com.facebook.react.bridge.NativeArray
|
||||
import com.facebook.react.bridge.NativeArrayInterface
|
||||
import com.facebook.react.bridge.NativeModule
|
||||
import com.facebook.react.bridge.NativeModuleRegistry
|
||||
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener
|
||||
import com.facebook.react.bridge.RuntimeExecutor
|
||||
import com.facebook.react.bridge.RuntimeScheduler
|
||||
import com.facebook.react.bridge.UIManager
|
||||
@@ -140,14 +139,6 @@ internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl)
|
||||
override val sourceURL: String
|
||||
get() = throw UnsupportedOperationException("Unimplemented method 'getSourceURL'")
|
||||
|
||||
override fun addBridgeIdleDebugListener(listener: NotThreadSafeBridgeIdleDebugListener) {
|
||||
throw UnsupportedOperationException("Unimplemented method 'addBridgeIdleDebugListener'")
|
||||
}
|
||||
|
||||
override fun removeBridgeIdleDebugListener(listener: NotThreadSafeBridgeIdleDebugListener) {
|
||||
throw UnsupportedOperationException("Unimplemented method 'removeBridgeIdleDebugListener'")
|
||||
}
|
||||
|
||||
override fun registerSegment(segmentId: Int, path: String) {
|
||||
throw UnsupportedOperationException("Unimplemented method 'registerSegment'")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user