Remove Coordinate update event
Summary: This idea did not pan out Reviewed By: lblasa Differential Revision: D42453231 fbshipit-source-id: 1feac79b8655f4249e84b64cdce9fded6e5f5718
This commit is contained in:
committed by
Facebook GitHub Bot
parent
412d10b280
commit
a6ab3f5649
@@ -38,17 +38,6 @@ data class SubtreeUpdateEvent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@kotlinx.serialization.Serializable
|
|
||||||
data class CoordinateUpdateEvent(
|
|
||||||
val observerType: String,
|
|
||||||
val nodeId: Id,
|
|
||||||
val coordinate: Coordinate
|
|
||||||
) {
|
|
||||||
companion object {
|
|
||||||
const val name = "coordinateUpdate"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Separate optional performance statistics event */
|
/** Separate optional performance statistics event */
|
||||||
@kotlinx.serialization.Serializable
|
@kotlinx.serialization.Serializable
|
||||||
data class PerfStatsEvent(
|
data class PerfStatsEvent(
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import com.facebook.flipper.plugins.uidebugger.common.BitmapPool
|
|||||||
import com.facebook.flipper.plugins.uidebugger.core.Context
|
import com.facebook.flipper.plugins.uidebugger.core.Context
|
||||||
import com.facebook.flipper.plugins.uidebugger.descriptors.Id
|
import com.facebook.flipper.plugins.uidebugger.descriptors.Id
|
||||||
import com.facebook.flipper.plugins.uidebugger.descriptors.MetadataRegister
|
import com.facebook.flipper.plugins.uidebugger.descriptors.MetadataRegister
|
||||||
import com.facebook.flipper.plugins.uidebugger.model.Coordinate
|
|
||||||
import com.facebook.flipper.plugins.uidebugger.model.CoordinateUpdateEvent
|
|
||||||
import com.facebook.flipper.plugins.uidebugger.model.MetadataUpdateEvent
|
import com.facebook.flipper.plugins.uidebugger.model.MetadataUpdateEvent
|
||||||
import com.facebook.flipper.plugins.uidebugger.model.Node
|
import com.facebook.flipper.plugins.uidebugger.model.Node
|
||||||
import com.facebook.flipper.plugins.uidebugger.model.PerfStatsEvent
|
import com.facebook.flipper.plugins.uidebugger.model.PerfStatsEvent
|
||||||
@@ -32,9 +30,6 @@ import kotlinx.serialization.json.Json
|
|||||||
|
|
||||||
sealed interface Update
|
sealed interface Update
|
||||||
|
|
||||||
data class CoordinateUpdate(val observerType: String, val nodeId: Id, val coordinate: Coordinate) :
|
|
||||||
Update
|
|
||||||
|
|
||||||
data class SubtreeUpdate(
|
data class SubtreeUpdate(
|
||||||
val observerType: String,
|
val observerType: String,
|
||||||
val rootId: Id,
|
val rootId: Id,
|
||||||
@@ -43,18 +38,18 @@ data class SubtreeUpdate(
|
|||||||
val traversalCompleteTime: Long,
|
val traversalCompleteTime: Long,
|
||||||
val snapshotComplete: Long,
|
val snapshotComplete: Long,
|
||||||
val snapshot: BitmapPool.ReusableBitmap?
|
val snapshot: BitmapPool.ReusableBitmap?
|
||||||
) : Update
|
)
|
||||||
|
|
||||||
/** Holds the root observer and manages sending updates to desktop */
|
/** Holds the root observer and manages sending updates to desktop */
|
||||||
class TreeObserverManager(val context: Context) {
|
class TreeObserverManager(val context: Context) {
|
||||||
|
|
||||||
private val rootObserver = ApplicationTreeObserver(context)
|
private val rootObserver = ApplicationTreeObserver(context)
|
||||||
private lateinit var updates: Channel<Update>
|
private lateinit var updates: Channel<SubtreeUpdate>
|
||||||
private var job: Job? = null
|
private var job: Job? = null
|
||||||
private val workerScope = CoroutineScope(Dispatchers.IO)
|
private val workerScope = CoroutineScope(Dispatchers.IO)
|
||||||
private val txId = AtomicInteger()
|
private val txId = AtomicInteger()
|
||||||
|
|
||||||
fun enqueueUpdate(update: Update) {
|
fun enqueueUpdate(update: SubtreeUpdate) {
|
||||||
updates.trySend(update)
|
updates.trySend(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,15 +67,8 @@ class TreeObserverManager(val context: Context) {
|
|||||||
workerScope.launch {
|
workerScope.launch {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
try {
|
try {
|
||||||
when (val update = updates.receive()) {
|
val update = updates.receive()
|
||||||
is SubtreeUpdate -> sendSubtreeUpdate(update)
|
sendSubtreeUpdate(update)
|
||||||
is CoordinateUpdate -> {
|
|
||||||
val event =
|
|
||||||
CoordinateUpdateEvent(update.observerType, update.nodeId, update.coordinate)
|
|
||||||
val serialized = Json.encodeToString(CoordinateUpdateEvent.serializer(), event)
|
|
||||||
context.connectionRef.connection?.send(CoordinateUpdateEvent.name, serialized)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: CancellationException) {} catch (e: java.lang.Exception) {
|
} catch (e: CancellationException) {} catch (e: java.lang.Exception) {
|
||||||
Log.e(LogTag, "Unexpected Error in channel ", e)
|
Log.e(LogTag, "Unexpected Error in channel ", e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user