Skip to content

Commit 0e03c02

Browse files
Fabio Carballofacebook-github-bot
authored andcommitted
Remove debug specific configurations from ComponentsConfiguration
Summary: ## Important This is a "copy" of D52563388, which was reverted due to three classes that were still referring to the old configurations and somehow Sandcastle missed. I'm updating those references on top of this copy. ## Original Description This diff removes debug specific configurations from `ComponentsConfiguration` in Litho into a new abstraction named `LithoDebugConfigurations`. The goal is that we move further into having `ComponentsConfiguration` to be more focused in internals/behaviors of Litho. Reviewed By: adityasharat Differential Revision: D52779201 fbshipit-source-id: 8f540efbe2691f7b8c22d1b199a14ff02f986c9c
1 parent 8fe6f93 commit 0e03c02

File tree

51 files changed

+201
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+201
-143
lines changed

litho-core/src/main/java/com/facebook/litho/Component.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import com.facebook.infer.annotation.ThreadSafe;
5959
import com.facebook.litho.annotations.EventHandlerRebindMode;
6060
import com.facebook.litho.config.ComponentsConfiguration;
61+
import com.facebook.litho.config.LithoDebugConfigurations;
6162
import com.facebook.litho.drawable.ComparableColorDrawable;
6263
import com.facebook.litho.drawable.ComparableDrawable;
6364
import com.facebook.rendercore.Equivalence;
@@ -2304,7 +2305,7 @@ static LinkedList<String> generateHierarchy(String globalKey) {
23042305
*/
23052306
@Nullable
23062307
private final AttributesHolder mDebugAttributesHolder =
2307-
ComponentsConfiguration.isDebugModeEnabled ? new AttributesHolder() : null;
2308+
LithoDebugConfigurations.isDebugModeEnabled ? new AttributesHolder() : null;
23082309

23092310
@Override
23102311
public <T> void setDebugAttributeKey(AttributeKey<T> attributeKey, T value) {

litho-core/src/main/java/com/facebook/litho/ComponentContextUtils.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.facebook.litho
1818

1919
import android.content.Context
2020
import com.facebook.litho.config.ComponentsConfiguration
21+
import com.facebook.litho.config.LithoDebugConfigurations
2122
import com.facebook.rendercore.visibility.VisibilityBoundsTransformer
2223

2324
object ComponentContextUtils {
@@ -37,7 +38,7 @@ object ComponentContextUtils {
3738
componentsConfig = ComponentsConfiguration.defaultInstance,
3839
areTransitionsEnabled = AnimationsDebug.areTransitionsEnabled(context),
3940
isVisibilityProcessingEnabled = true,
40-
incrementalMountEnabled = !ComponentsConfiguration.isIncrementalMountGloballyDisabled,
41+
incrementalMountEnabled = !LithoDebugConfigurations.isIncrementalMountGloballyDisabled,
4142
errorEventHandler = DefaultErrorEventHandler.INSTANCE,
4243
logTag = logTagToUse,
4344
logger = loggerToUse,

litho-core/src/main/java/com/facebook/litho/ComponentTree.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import com.facebook.infer.annotation.ThreadSafe;
7575
import com.facebook.litho.LithoLifecycleProvider.LithoLifecycle;
7676
import com.facebook.litho.config.ComponentsConfiguration;
77+
import com.facebook.litho.config.LithoDebugConfigurations;
7778
import com.facebook.litho.debug.AttributionUtils;
7879
import com.facebook.litho.debug.DebugOverlay;
7980
import com.facebook.litho.debug.LithoDebugEvent;
@@ -521,7 +522,7 @@ protected ComponentTree(Builder builder) {
521522
null,
522523
builder.parentTreeProps);
523524

524-
if (ComponentsConfiguration.isTimelineEnabled) {
525+
if (LithoDebugConfigurations.isTimelineEnabled) {
525526
mTimeMachine = new DebugComponentTreeTimeMachine(this);
526527
} else {
527528
mTimeMachine = null;
@@ -559,7 +560,7 @@ protected ComponentTree(Builder builder) {
559560
}
560561

561562
private static boolean incrementalMountGloballyDisabled() {
562-
return ComponentsConfiguration.isIncrementalMountGloballyDisabled;
563+
return LithoDebugConfigurations.isIncrementalMountGloballyDisabled;
563564
}
564565

565566
/**

litho-core/src/main/java/com/facebook/litho/DebugDraw.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import android.graphics.Paint
2222
import android.graphics.Rect
2323
import android.graphics.drawable.Drawable
2424
import android.view.View
25-
import com.facebook.litho.config.ComponentsConfiguration
25+
import com.facebook.litho.config.LithoDebugConfigurations
2626

2727
/** Draw operations used in developer options. */
2828
internal object DebugDraw {
@@ -56,10 +56,10 @@ internal object DebugDraw {
5656

5757
@JvmStatic
5858
fun draw(host: ComponentHost, canvas: Canvas) {
59-
if (ComponentsConfiguration.debugHighlightInteractiveBounds) {
59+
if (LithoDebugConfigurations.debugHighlightInteractiveBounds) {
6060
highlightInteractiveBounds(host, canvas)
6161
}
62-
if (ComponentsConfiguration.debugHighlightMountBounds) {
62+
if (LithoDebugConfigurations.debugHighlightMountBounds) {
6363
highlightMountBounds(host, canvas)
6464
}
6565
}

litho-core/src/main/java/com/facebook/litho/DefaultComponentsReporter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.facebook.litho
1818

1919
import android.util.Log
20-
import com.facebook.litho.config.ComponentsConfiguration
20+
import com.facebook.litho.config.LithoDebugConfigurations
2121
import com.facebook.rendercore.ErrorReporterDelegate
2222
import com.facebook.rendercore.LogLevel
2323
import java.lang.RuntimeException
@@ -59,7 +59,7 @@ open class DefaultComponentsReporter : ErrorReporterDelegate {
5959
}
6060

6161
private fun applyOnInternalBuild(block: () -> Unit) {
62-
if (ComponentsConfiguration.IS_INTERNAL_BUILD) {
62+
if (LithoDebugConfigurations.isDebugModeEnabled) {
6363
block()
6464
}
6565
}

litho-core/src/main/java/com/facebook/litho/DefaultComponentsSystrace.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.facebook.litho
1818

1919
import android.os.Build
2020
import android.os.Trace
21-
import com.facebook.litho.config.ComponentsConfiguration
21+
import com.facebook.litho.config.LithoDebugConfigurations
2222
import com.facebook.rendercore.RenderCoreSystrace
2323
import com.facebook.rendercore.Systracer
2424
import com.facebook.rendercore.Systracer.ArgsBuilder
@@ -57,7 +57,7 @@ open class DefaultComponentsSystrace : Systracer {
5757
}
5858

5959
override fun isTracing(): Boolean =
60-
ComponentsConfiguration.IS_INTERNAL_BUILD &&
60+
LithoDebugConfigurations.isDebugModeEnabled &&
6161
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 &&
6262
(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || Trace.isEnabled())
6363

litho-core/src/main/java/com/facebook/litho/LayoutState.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.facebook.litho.EndToEndTestingExtension.EndToEndTestingExtensionInput;
3434
import com.facebook.litho.LithoViewAttributesExtension.ViewAttributesInput;
3535
import com.facebook.litho.config.ComponentsConfiguration;
36+
import com.facebook.litho.config.LithoDebugConfigurations;
3637
import com.facebook.rendercore.LayoutCache;
3738
import com.facebook.rendercore.LayoutResult;
3839
import com.facebook.rendercore.MountItemsPool;
@@ -679,7 +680,8 @@ public TransitionId getRootTransitionId() {
679680

680681
/** Debug-only: return a string representation of this LayoutState and its LayoutOutputs. */
681682
String dumpAsString() {
682-
if (!ComponentsConfiguration.isDebugModeEnabled && !ComponentsConfiguration.isEndToEndTestRun) {
683+
if (!LithoDebugConfigurations.isDebugModeEnabled
684+
&& !ComponentsConfiguration.isEndToEndTestRun) {
683685
throw new RuntimeException(
684686
"LayoutState#dumpAsString() should only be called in debug mode or from e2e tests!");
685687
}

litho-core/src/main/java/com/facebook/litho/LithoNode.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import com.facebook.infer.annotation.ThreadConfined
3737
import com.facebook.litho.CommonProps.DefaultLayoutProps
3838
import com.facebook.litho.Transition.TransitionKeyType
3939
import com.facebook.litho.annotations.ImportantForAccessibility
40-
import com.facebook.litho.config.ComponentsConfiguration
40+
import com.facebook.litho.config.LithoDebugConfigurations
4141
import com.facebook.litho.drawable.ComparableColorDrawable
4242
import com.facebook.rendercore.LayoutCache
4343
import com.facebook.rendercore.LayoutContext
@@ -103,7 +103,7 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
103103

104104
val debugLayoutEditor: LayoutProps?
105105
get() {
106-
if (ComponentsConfiguration.isDebugModeEnabled && debugLayoutProps == null) {
106+
if (LithoDebugConfigurations.isDebugModeEnabled && debugLayoutProps == null) {
107107
debugLayoutProps = DefaultLayoutProps()
108108
}
109109
return debugLayoutProps
@@ -1470,7 +1470,7 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
14701470
}
14711471

14721472
private fun applyOverridesRecursive(node: LithoNode) {
1473-
if (ComponentsConfiguration.isDebugModeEnabled) {
1473+
if (LithoDebugConfigurations.isDebugModeEnabled) {
14741474
DebugComponent.applyOverrides(node.tailComponentContext, node)
14751475
for (i in 0 until node.childCount) {
14761476
applyOverridesRecursive(node.getChildAt(i))

litho-core/src/main/java/com/facebook/litho/LithoNodeUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import androidx.core.view.ViewCompat
2424
import com.facebook.litho.Component.MountType
2525
import com.facebook.litho.MountSpecLithoRenderUnit.UpdateState
2626
import com.facebook.litho.annotations.ImportantForAccessibility
27-
import com.facebook.litho.config.ComponentsConfiguration
27+
import com.facebook.litho.config.LithoDebugConfigurations
2828
import com.facebook.litho.drawable.BorderColorDrawable
2929
import com.facebook.rendercore.LayoutResult
3030
import com.facebook.rendercore.MountState
@@ -397,7 +397,7 @@ object LithoNodeUtils {
397397

398398
@JvmStatic
399399
fun getDebugKey(componentKey: String?, @OutputUnitType outputUnitType: Int): String? =
400-
if (ComponentsConfiguration.isDebugModeEnabled) {
400+
if (LithoDebugConfigurations.isDebugModeEnabled) {
401401
null
402402
} else {
403403
when (outputUnitType) {

litho-core/src/main/java/com/facebook/litho/LithoReducer.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import android.graphics.Rect
2020
import androidx.collection.LongSparseArray
2121
import androidx.core.view.ViewCompat
2222
import com.facebook.litho.config.ComponentsConfiguration
23+
import com.facebook.litho.config.LithoDebugConfigurations
2324
import com.facebook.rendercore.LayoutResult
2425
import com.facebook.rendercore.MountState
2526
import com.facebook.rendercore.RenderTreeNode
@@ -130,7 +131,7 @@ object LithoReducer {
130131
layoutState.mLayoutResult = null
131132

132133
// enabled for debugging and end to end tests
133-
if (ComponentsConfiguration.isDebugModeEnabled || ComponentsConfiguration.isEndToEndTestRun) {
134+
if (LithoDebugConfigurations.isDebugModeEnabled || ComponentsConfiguration.isEndToEndTestRun) {
134135
layoutState.mRoot = nodeForSaving
135136
layoutState.mLayoutResult = layoutResultForSaving
136137
return
@@ -902,7 +903,7 @@ object LithoReducer {
902903
private fun LithoNode.getDebugHierarchy(
903904
parentHierarchy: DebugHierarchy.Node? = null,
904905
): DebugHierarchy.Node? {
905-
if (!ComponentsConfiguration.isDebugHierarchyEnabled) {
906+
if (!LithoDebugConfigurations.isDebugHierarchyEnabled) {
906907
return null
907908
}
908909
val infos: List<ScopedComponentInfo> = scopedComponentInfos

litho-core/src/main/java/com/facebook/litho/Resolver.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.facebook.litho
1818

1919
import androidx.annotation.IntDef
2020
import androidx.annotation.VisibleForTesting
21-
import com.facebook.litho.config.ComponentsConfiguration
21+
import com.facebook.litho.config.LithoDebugConfigurations
2222
import com.facebook.litho.debug.LithoDebugEvent
2323
import com.facebook.litho.debug.LithoDebugEventAttributes
2424
import com.facebook.rendercore.debug.DebugEventDispatcher
@@ -378,7 +378,7 @@ object Resolver {
378378
c.treeProps = descendants
379379
}
380380

381-
if (ComponentsConfiguration.isDebugModeEnabled) {
381+
if (LithoDebugConfigurations.isDebugModeEnabled) {
382382
DebugComponent.applyOverrides(c, component, c.globalKey)
383383
}
384384
return c

litho-core/src/main/java/com/facebook/litho/StateDebuggingUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
package com.facebook.litho
1818

19-
import com.facebook.litho.config.ComponentsConfiguration
19+
import com.facebook.litho.config.LithoDebugConfigurations
2020

2121
/** Hosts API to debug state */
2222
val KStateContainer.state: List<Any?>
2323
get() =
24-
if (ComponentsConfiguration.isDebugModeEnabled) {
24+
if (LithoDebugConfigurations.isDebugModeEnabled) {
2525
states
2626
} else {
2727
error("State should only be read by debugging utilities.")

litho-core/src/main/java/com/facebook/litho/ThreadUtils.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import android.os.Process
2121
import androidx.annotation.IntDef
2222
import androidx.annotation.VisibleForTesting
2323
import com.facebook.litho.config.ComponentsConfiguration
24+
import com.facebook.litho.config.LithoDebugConfigurations
2425

2526
/** Thread assertion utilities. */
2627
object ThreadUtils {
@@ -61,15 +62,15 @@ object ThreadUtils {
6162

6263
@JvmStatic
6364
fun assertHoldsLock(lock: Any) {
64-
if (!ComponentsConfiguration.IS_INTERNAL_BUILD) {
65+
if (!LithoDebugConfigurations.isDebugModeEnabled) {
6566
return
6667
}
6768
check(Thread.holdsLock(lock)) { "This method should be called while holding the lock" }
6869
}
6970

7071
@JvmStatic
7172
fun assertDoesntHoldLock(lock: Any) {
72-
if (!ComponentsConfiguration.IS_INTERNAL_BUILD) {
73+
if (!LithoDebugConfigurations.isDebugModeEnabled) {
7374
return
7475
}
7576
check(!Thread.holdsLock(lock)) { "This method should be called outside the lock." }

litho-core/src/main/java/com/facebook/litho/config/ComponentsConfiguration.kt

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,31 @@ internal constructor(
7676

7777
companion object {
7878

79-
@JvmField var defaultInstance: ComponentsConfiguration = ComponentsConfiguration()
79+
/**
80+
* This is just a proxy to [LithoDebugConfigurations.isDebugModeEnabled]. We have to keep it
81+
* until we release a new oss version and we can refer to [LithoDebugConfigurations] directly on
82+
* Flipper.
83+
*/
84+
@Deprecated("Use the LithoDebugConfigurations instead")
85+
var isDebugModeEnabled: Boolean
86+
get() = LithoDebugConfigurations.isDebugModeEnabled
87+
set(value) {
88+
LithoDebugConfigurations.isDebugModeEnabled = value
89+
}
8090

8191
/**
82-
* Indicates whether this is an internal build. Note that the implementation of `BuildConfig ` *
83-
* that this class is compiled against may not be the one that is included in the APK. See:
84-
* [android_build_config](http://facebook.github.io/buck/rule/android_build_config.html).
92+
* This is just a proxy to [LithoDebugConfigurations.isDebugHierarchyEnabled]. We have to keep
93+
* it until we release a new oss version and we can refer to [LithoDebugConfigurations] directly
94+
* on Flipper.
8595
*/
86-
@JvmField val IS_INTERNAL_BUILD: Boolean = BuildConfig.IS_INTERNAL_BUILD
96+
@Deprecated("Use the LithoDebugConfigurations instead")
97+
var isDebugHierarchyEnabled: Boolean
98+
get() = LithoDebugConfigurations.isDebugHierarchyEnabled
99+
set(value) {
100+
LithoDebugConfigurations.isDebugHierarchyEnabled = value
101+
}
102+
103+
@JvmField var defaultInstance: ComponentsConfiguration = ComponentsConfiguration()
87104

88105
/** Indicates that the incremental mount helper is required for this build. */
89106
@JvmField val USE_INCREMENTAL_MOUNT_HELPER: Boolean = BuildConfig.USE_INCREMENTAL_MOUNT_HELPER
@@ -105,21 +122,6 @@ internal constructor(
105122
*/
106123
const val DEFAULT_CHANGE_SET_THREAD_PRIORITY: Int = 0
107124

108-
@JvmField var isDebugModeEnabled: Boolean = IS_INTERNAL_BUILD
109-
110-
/**
111-
* Option to enabled debug mode. This will save extra data associated with each node and allow
112-
* more info about the hierarchy to be retrieved. Used to enable stetho integration. It is
113-
* highly discouraged to enable this in production builds. Due to how the Litho releases are
114-
* distributed in open source IS_INTERNAL_BUILD will always be false. It is therefore required
115-
* to override this value using your own application build configs. Recommended place for this
116-
* is in a Application subclass onCreate() method.
117-
*/
118-
@JvmField var isRenderInfoDebuggingEnabled: Boolean = isDebugModeEnabled
119-
120-
/** Lightweight tracking of component class hierarchy of MountItems. */
121-
@JvmField var isDebugHierarchyEnabled: Boolean = false
122-
123125
/**
124126
* Populates additional metadata to find mounted components at runtime. Defaults to the presence
125127
* of an
@@ -158,9 +160,6 @@ internal constructor(
158160
*/
159161
@JvmField var computeRangeOnSyncLayout: Boolean = false
160162

161-
/** When `true`, disables incremental mount globally. */
162-
@JvmField var isIncrementalMountGloballyDisabled: Boolean = false
163-
164163
/** Keeps the litho layout result tree in the LayoutState. This will increase memory use. */
165164
@JvmField var keepLayoutResults: Boolean = false
166165

@@ -173,10 +172,6 @@ internal constructor(
173172

174173
@JvmField var hostComponentPoolSize: Int = 30
175174

176-
/** When `true` ComponentTree records state change snapshots */
177-
@JvmField var isTimelineEnabled: Boolean = isRenderInfoDebuggingEnabled
178-
@JvmField var timelineDocsLink: String? = null
179-
180175
/** Skip checking for root component and tree-props while layout */
181176
@JvmField var isSkipRootCheckingEnabled: Boolean = false
182177
@JvmField var enableComputeLayoutAsyncAfterInsertion: Boolean = true
@@ -206,14 +201,7 @@ internal constructor(
206201
@JvmField var bindOnSameComponentTree: Boolean = true
207202
@JvmField var enableStateUpdatesBatching: Boolean = true
208203
@JvmField var componentsLogger: ComponentsLogger? = null
209-
210-
/** Debug option to highlight interactive areas in mounted components. */
211-
@JvmField var debugHighlightInteractiveBounds: Boolean = false
212-
213-
/** Debug option to highlight mount bounds of mounted components. */
214-
@JvmField var debugHighlightMountBounds: Boolean = false
215204
@JvmField var isEventHandlerRebindLoggingEnabled: Boolean = false
216-
@JvmField var eventHandlerRebindLoggingSamplingRate: Int = 0
217205
@JvmField var isObjectTreePropEnabled: Boolean = false
218206

219207
/**

0 commit comments

Comments
 (0)