Take snapshot on subtree update

Summary:
DecorView owns a BitmapPool to take snapshots of the view. These snapshots are later on serialised by the manager.

There's a couple of unrelated changes in this diff but that were already in place making it hard to split.

(1) Renamed 'traverseAndSend' to 'processUpdate'. Why?

The observers as a whole shouldn't necessary know that their 'observation' is being sent to any place. Future changes should move the send logic altogether from the observer too. But that can be made within the scope of a different diff.

(2) There was a bug for nodes that were being observed but then unsubscribed from. If the nodes were being marked for observation and observer was already into place, these were not being told to subscribe again for changes.

Reviewed By: LukeDefeo

Differential Revision: D39812943

fbshipit-source-id: af98c5caf54e1c69f97043bae95049395a2e4545
This commit is contained in:
Lorenzo Blasa
2022-09-27 13:00:04 -07:00
committed by Facebook GitHub Bot
parent 7017d74821
commit 433061d377
6 changed files with 106 additions and 46 deletions

View File

@@ -19,7 +19,7 @@ class LithoViewTreeObserver(val context: Context) : TreeObserver<LithoView>() {
override val type = "Litho"
var nodeRef: LithoView? = null
private var nodeRef: LithoView? = null
override fun subscribe(node: Any) {
@@ -27,7 +27,7 @@ class LithoViewTreeObserver(val context: Context) : TreeObserver<LithoView>() {
nodeRef = node as LithoView
val listener: (view: LithoView) -> Unit = { traverseAndSend(context, node) }
val listener: (view: LithoView) -> Unit = { processUpdate(context, node) }
node.setOnDirtyMountListener(listener)
listener(node)