Skip to content

Commit 1e21c9e

Browse files
hoxyqfacebook-github-bot
authored andcommitted
PerfMonitor to subscribe to InspectorTarget tracing events (facebook#54825)
Summary: # Changelog: [Internal] Removed manual propagation of the tracing state in `ReactHostInspectorTarget.kt`. The `jsinspector-modern` should be the centralised and the only source of truth for tracing state. Reviewed By: huntie Differential Revision: D88734483
1 parent 0b002fb commit 1e21c9e

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostInspectorTarget.kt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,19 @@ internal class ReactHostInspectorTarget(reactHostImpl: ReactHostImpl) :
5353

5454
override fun addPerfMonitorListener(listener: PerfMonitorUpdateListener) {
5555
perfMonitorListeners.add(listener)
56+
registerTracingStateListener { state, _ -> listener.onRecordingStateChanged(state) }
5657
}
5758

5859
override fun pauseAndAnalyzeBackgroundTrace(): Boolean {
59-
val emitted = stopAndMaybeEmitBackgroundTrace()
60-
perfMonitorListeners.forEach { listener ->
61-
listener.onRecordingStateChanged(TracingState.DISABLED)
62-
}
63-
64-
return emitted
60+
return stopAndMaybeEmitBackgroundTrace()
6561
}
6662

6763
override fun resumeBackgroundTrace() {
6864
startBackgroundTrace()
69-
perfMonitorListeners.forEach { listener ->
70-
listener.onRecordingStateChanged(TracingState.ENABLED_IN_BACKGROUND_MODE)
71-
}
7265
}
7366

7467
override fun stopBackgroundTrace() {
7568
stopAndDiscardBackgroundTrace()
76-
perfMonitorListeners.forEach { listener ->
77-
listener.onRecordingStateChanged(TracingState.DISABLED)
78-
}
7969
}
8070

8171
fun handleNativePerfIssueAdded(

0 commit comments

Comments
 (0)