-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix two race conditions in RecyclerBinder. #917
base: master
Are you sure you want to change the base?
Conversation
If the collection has not completed initial layout by the time onNewWorkingRange() is called, it will short circuit and not be called again. If a collection item has not completed initial layout by the time we attempt to check if it belongs to a working range, the call noop-s and is not attempted again. In each case, save the working range and apply it when the layout completes.
Fix two race conditions in RecyclerBinder.
Thank you for contributing 😃 |
Done! |
@pentiumao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@@ -2689,6 +2713,15 @@ private synchronized void commitResolutionResult( | |||
if (mTreeState != null) { | |||
mTreeState.unregisterRenderState(resolutionResult.treeState); | |||
} | |||
|
|||
WorkingRangeAndPositionHolder workingRangeAndPosition = null; | |||
synchronized (this) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lock seems unnecessary, because commitResolutionResult
is synchronized. Can we remove it?
@@ -116,6 +118,9 @@ interface ComponentTreeMeasureListenerFactory { | |||
@GuardedBy("this") | |||
private int mLastRequestedHeightSpec = UNINITIALIZED; | |||
|
|||
@GuardedBy("this") | |||
private WorkingRangeAndPositionHolder mPendingWorkingRangeAndPosition = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add @nullable to this field to make it Nullsafe?
@@ -221,6 +223,8 @@ public void run() { | |||
private final RunnableHandler mPreallocateMountContentHandler; | |||
private final boolean mPreallocatePerMountSpec; | |||
|
|||
private @Nullable WorkingRangeHolder mPendingWorkingRange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This private field is never accessed, can you clarify its purpose? Thanks!
lastFullyVisibleIndex))); | ||
} | ||
|
||
synchronized void checkWorkingRangeAndDispatch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
If the collection has not completed initial layout by the time onNewWorkingRange() is called, it will short circuit and not be called again.
If a collection item has not completed initial layout by the time we attempt to check if it belongs to a working range, the call noop-s and is not attempted again.
In each case, save the working range and apply it when the layout completes.
Changelog
Fix two race conditions in RecyclerBinder.
Test Plan
Want to get feedback on my approach first.