Skip to content

Commit

Permalink
Ship skipping null state updates
Browse files Browse the repository at this point in the history
Summary: The experiment results are neutral, there are no regressions or other issues. We can ship skipping state updates when the old and new value is null.

Reviewed By: apowolny

Differential Revision: D60572677

fbshipit-source-id: dbc3898e90e1bdcc57f58449b7baa4e3a69f05f9
  • Loading branch information
zielinskimz authored and facebook-github-bot committed Aug 1, 2024
1 parent d5587ff commit 97bcf0a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
5 changes: 1 addition & 4 deletions litho-core/src/main/java/com/facebook/litho/TreeState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.facebook.litho
import android.util.Pair
import androidx.annotation.VisibleForTesting
import com.facebook.litho.Component.RenderData
import com.facebook.litho.config.ComponentsConfiguration
import com.facebook.litho.internal.HookKey
import com.facebook.rendercore.annotations.UIState

Expand Down Expand Up @@ -245,9 +244,7 @@ class TreeState {
): Boolean {
val stateHandler = getStateHandler(isNestedTree)
val committedState = stateHandler.getStateContainer(globalKey) as KStateContainer?
if (committedState != null &&
(ComponentsConfiguration.enableSkipNullStateUpdates ||
committedState.states.getOrNull(hookStateIndex) != null)) {
if (committedState != null) {
val committedStateWithUpdatesApplied =
stateHandler.getStateContainerWithHookUpdates(globalKey)
if (committedStateWithUpdatesApplied != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,6 @@ internal constructor(
* NaN or Infinity.
*/
@JvmField var enableLoggingForInvalidAspectRatio: Boolean = false
/**
* This flag is used to enable a change where a state update is skipped if the current and new
* state value are null.
*/
@JvmField var enableSkipNullStateUpdates: Boolean = false
/** This flag is used to enable a fix for the ANR issue with sticky header RecyclerView. */
@JvmField var enableFixForStickyHeader: Boolean = false

Expand Down
8 changes: 1 addition & 7 deletions litho-core/src/test/kotlin/com/facebook/litho/KStateTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.facebook.litho
import android.view.View
import com.facebook.litho.SizeSpec.EXACTLY
import com.facebook.litho.accessibility.contentDescription
import com.facebook.litho.config.ComponentsConfiguration
import com.facebook.litho.core.height
import com.facebook.litho.core.width
import com.facebook.litho.kotlin.widget.Text
Expand Down Expand Up @@ -604,12 +603,7 @@ class KStateTest {

lithoViewRule.act(testLithoView) { clickOnTag("test_view") }

// TODO clean up when experiment concluded
if (ComponentsConfiguration.enableSkipNullStateUpdates) {
assertThat(renderCount.get()).isEqualTo(1)
} else {
assertThat(renderCount.get()).isEqualTo(2)
}
assertThat(renderCount.get()).isEqualTo(1)
}

private class CountDownLatchComponent(
Expand Down

0 comments on commit 97bcf0a

Please sign in to comment.