Skip to content

Commit

Permalink
ensure render units have unique ids across the tree
Browse files Browse the repository at this point in the history
Summary:
Now that we want to track render unit execution, we need to make sure that the associated client id of the render unit signal/scope is globally unique.
https://www.internalfb.com/code/fbsource/[D62641845-V1]/fbandroid/libraries/bloks/bloks/src/main/java/com/instagram/common/bloks/signals/Type.kt?lines=65

To do this we need to override the ids of render units produced from the resolve step and layout. The mount phase will read the render unit id (which is now the client id) and use it to track signal accesses

NOTE: For layout we only override the id (by wrapping) if the id of the render unit is different from the client id of the model that produced it. We're banking on the reality that ~95% of component implementations use or extend `BloksUntypedRenderUnit` whose render unit id is the same as the client id of the model it was produced from. This way, we can ensure that we're allocating only where necessary.

Reviewed By: rooju

Differential Revision: D62642517

fbshipit-source-id: 537a1419ec4ba7dd211875a8976c8330bcdbc32c
  • Loading branch information
Daniel Famakin authored and facebook-github-bot committed Sep 20, 2024
1 parent 105106a commit 837ce10
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import androidx.annotation.IdRes
*/
// Don't add support for fixedMountBinders in WrapperRenderUnit unless you add support for them in
// BindData handling logic.
class WrapperRenderUnit<ContentType : Any>(private val renderUnit: RenderUnit<ContentType>) :
class WrapperRenderUnit<ContentType : Any>
@JvmOverloads
constructor(private val renderUnit: RenderUnit<ContentType>, idOverride: Long = renderUnit.id) :
RenderUnit<ContentType>(renderUnit.renderType) {

override val id: Long = renderUnit.id
override val id: Long = idOverride

override val contentAllocator: ContentAllocator<ContentType> = renderUnit.contentAllocator

Expand Down

0 comments on commit 837ce10

Please sign in to comment.