Skip to content

Commit

Permalink
Codeship the fix for the race of async update
Browse files Browse the repository at this point in the history
Summary: Since we've shipped the fix through GK(D63130683), this diff is to code ship the change.

Reviewed By: jettbow

Differential Revision: D64042507

fbshipit-source-id: 06b4fe6c5c2a9d0c34c94d5cb25d25e260003238
  • Loading branch information
Andrew Wang authored and facebook-github-bot committed Oct 8, 2024
1 parent 4fdfc77 commit 06360fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 44 deletions.
46 changes: 8 additions & 38 deletions litho-core/src/main/java/com/facebook/litho/ComponentTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -1889,21 +1889,15 @@ private void requestRenderWithSplitFutures(
}
}

if (ComponentsConfiguration.enableFixForTheRaceOfAsyncUpdates) {
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoResolveRunnable != null) {
mLayoutThreadHandler.remove(mCurrentDoResolveRunnable);
mCurrentDoResolveRunnable = null;
}
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoResolveRunnable != null) {
mLayoutThreadHandler.remove(mCurrentDoResolveRunnable);
mCurrentDoResolveRunnable = null;
}
}

if (isAsync) {
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoResolveRunnable != null
&& !ComponentsConfiguration.enableFixForTheRaceOfAsyncUpdates) {
mLayoutThreadHandler.remove(mCurrentDoResolveRunnable);
}
mCurrentDoResolveRunnable =
new DoResolveRunnable(
source, root, treePropContainer, widthSpec, heightSpec, extraAttribution);
Expand Down Expand Up @@ -1931,15 +1925,6 @@ private void doResolve(
final int widthSpec,
final int heightSpec) {

if (!ComponentsConfiguration.enableFixForTheRaceOfAsyncUpdates) {
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoResolveRunnable != null) {
mLayoutThreadHandler.remove(mCurrentDoResolveRunnable);
mCurrentDoResolveRunnable = null;
}
}
}

final int localResolveVersion;
final TreeState treeState;
final ComponentContext context;
Expand Down Expand Up @@ -2088,21 +2073,15 @@ private void requestLayoutWithSplitFutures(
"Cannot generate output for async layout calculation (source = " + source + ")");
}

if (ComponentsConfiguration.enableFixForTheRaceOfAsyncUpdates) {
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoLayoutRunnable != null) {
mLayoutThreadHandler.remove(mCurrentDoLayoutRunnable);
mCurrentDoLayoutRunnable = null;
}
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoLayoutRunnable != null) {
mLayoutThreadHandler.remove(mCurrentDoLayoutRunnable);
mCurrentDoLayoutRunnable = null;
}
}

if (isAsync && !forceSyncCalculation) {
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoLayoutRunnable != null
&& !ComponentsConfiguration.enableFixForTheRaceOfAsyncUpdates) {
mLayoutThreadHandler.remove(mCurrentDoLayoutRunnable);
}
mCurrentDoLayoutRunnable =
new DoLayoutRunnable(resolveResult, source, widthSpec, heightSpec, extraAttribution);

Expand All @@ -2128,15 +2107,6 @@ private void doLayout(
final int widthSpec,
final int heightSpec) {

if (!ComponentsConfiguration.enableFixForTheRaceOfAsyncUpdates) {
synchronized (mCurrentDoLayoutRunnableLock) {
if (mCurrentDoLayoutRunnable != null) {
mLayoutThreadHandler.remove(mCurrentDoLayoutRunnable);
mCurrentDoLayoutRunnable = null;
}
}
}

final int layoutVersion;
final @Nullable LayoutState currentLayoutState;
final @Nullable DiffNode currentDiffNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,6 @@ internal constructor(
/** This flag is used to enable a fix for the ANR issue with sticky header RecyclerView. */
@JvmField var enableFixForStickyHeader: Boolean = false

/**
* This flag is used to enable a fix for the race condition when two async updates are happening
* at the same time.
*/
@JvmField var enableFixForTheRaceOfAsyncUpdates: Boolean = false

/** This flag is used to enable a fix for the primitive component measurement issue. */
@JvmField var enablePrimitiveMeasurementFix: Boolean = false

Expand Down

0 comments on commit 06360fa

Please sign in to comment.