diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/NativeScanScheduler.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/NativeScanScheduler.kt index 2a3b1e6a0..b97773610 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/NativeScanScheduler.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/NativeScanScheduler.kt @@ -10,9 +10,10 @@ package com.facebook.flipper.plugins.uidebugger.core import android.os.Looper import android.util.Log import com.facebook.flipper.plugins.uidebugger.LogTag -import com.facebook.flipper.plugins.uidebugger.model.NativeScanEvent +import com.facebook.flipper.plugins.uidebugger.descriptors.nodeId import com.facebook.flipper.plugins.uidebugger.model.Node import com.facebook.flipper.plugins.uidebugger.model.PerfStatsEvent +import com.facebook.flipper.plugins.uidebugger.model.SubtreeUpdateEvent import com.facebook.flipper.plugins.uidebugger.observers.TreeObserverFactory import com.facebook.flipper.plugins.uidebugger.scheduler.Scheduler import com.facebook.flipper.plugins.uidebugger.traversal.PartialLayoutTraversal @@ -25,6 +26,8 @@ data class ScanResult( val nodes: List ) +const val observerType = "FullScan" + /** This is used to stress test the ui debugger, should not be used in production */ class NativeScanScheduler(val context: Context) : Scheduler.Task { /** @@ -33,7 +36,7 @@ class NativeScanScheduler(val context: Context) : Scheduler.Task { */ private val emptyObserverFactory = TreeObserverFactory() private val traversal = PartialLayoutTraversal(context.descriptorRegister, emptyObserverFactory) - private var txId = 0L + private var txId = 100000L override fun execute(): ScanResult { val start = System.currentTimeMillis() @@ -49,11 +52,14 @@ class NativeScanScheduler(val context: Context) : Scheduler.Task { override fun process(input: ScanResult) { val serialized = - Json.encodeToString(NativeScanEvent.serializer(), NativeScanEvent(input.txId, input.nodes)) + Json.encodeToString( + SubtreeUpdateEvent.serializer(), + SubtreeUpdateEvent( + input.txId, observerType, context.applicationRef.nodeId(), input.nodes)) val serializationEnd = System.currentTimeMillis() context.connectionRef.connection?.send( - NativeScanEvent.name, + SubtreeUpdateEvent.name, serialized, ) val socketEnd = System.currentTimeMillis() @@ -64,7 +70,7 @@ class NativeScanScheduler(val context: Context) : Scheduler.Task { PerfStatsEvent.serializer(), PerfStatsEvent( input.txId, - "FullScan", + observerType, input.scanStart, input.scanStart, input.scanEnd, diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/Events.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/Events.kt index 57b8f6920..6777ab8bb 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/Events.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/model/Events.kt @@ -29,13 +29,6 @@ data class SubtreeUpdateEvent( } } -@kotlinx.serialization.Serializable -data class NativeScanEvent(val txId: Long, val nodes: List) { - companion object { - const val name = "nativeScan" - } -} - /** Separate optional performance statistics event */ @kotlinx.serialization.Serializable data class PerfStatsEvent( diff --git a/desktop/plugins/public/ui-debugger/index.tsx b/desktop/plugins/public/ui-debugger/index.tsx index 2a82b966e..6b9e57995 100644 --- a/desktop/plugins/public/ui-debugger/index.tsx +++ b/desktop/plugins/public/ui-debugger/index.tsx @@ -35,11 +35,6 @@ export function plugin(client: PluginClient) { }); }); - client.onMessage('nativeScan', ({nodes}) => { - //Native scan is a full update so overwrite everything - nodesAtom.set(new Map(nodes.map((node) => [node.id, node]))); - }); - return {rootId, snapshots: snapshotsAtom, nodes: nodesAtom, perfEvents}; } diff --git a/desktop/plugins/public/ui-debugger/types.tsx b/desktop/plugins/public/ui-debugger/types.tsx index 773bd8c24..4c9a54b71 100644 --- a/desktop/plugins/public/ui-debugger/types.tsx +++ b/desktop/plugins/public/ui-debugger/types.tsx @@ -8,8 +8,7 @@ */ export type Events = { - init: {rootId: string}; - nativeScan: {txId: number; nodes: UINode[]}; + init: InitEvent; subtreeUpdate: SubtreeUpdateEvent; perfStats: PerfStatsEvent; }; @@ -21,6 +20,8 @@ export type SubtreeUpdateEvent = { snapshot: Snapshot; }; +export type InitEvent = {rootId: Id}; + export type PerfStatsEvent = { txId: number; observerType: string; @@ -50,8 +51,8 @@ export type Bounds = { height: number; }; -export type Id = string; export type Snapshot = string; +export type Id = number; export type Tag = 'Native' | 'Declarative' | 'Android' | 'Litho ';