-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Fix crash in getChildDrawingOrder #40859
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,9 +11,13 @@ | |||||||||
| import android.view.ViewGroup; | ||||||||||
| import androidx.annotation.Nullable; | ||||||||||
| import java.util.ArrayList; | ||||||||||
| import java.util.Arrays; | ||||||||||
| import java.util.Collections; | ||||||||||
| import java.util.Comparator; | ||||||||||
|
|
||||||||||
| import com.facebook.common.logging.FLog; | ||||||||||
| import com.facebook.react.common.ReactConstants; | ||||||||||
|
|
||||||||||
| /** Helper to handle implementing ViewGroups with custom drawing order based on z-index. */ | ||||||||||
| public class ViewGroupDrawingOrderHelper { | ||||||||||
| private final ViewGroup mViewGroup; | ||||||||||
|
|
@@ -65,6 +69,20 @@ public boolean shouldEnableCustomDrawingOrder() { | |||||||||
| * ViewGroup#getChildDrawingOrder}. | ||||||||||
| */ | ||||||||||
| public int getChildDrawingOrder(int childCount, int index) { | ||||||||||
| if (mDrawingOrderIndices != null | ||||||||||
| && (index >= mDrawingOrderIndices.length || mDrawingOrderIndices[index] >= childCount)) { | ||||||||||
| FLog.w(ReactConstants.TAG, | ||||||||||
| "getChildDrawingOrder index out of bounds! please check your operations of addding and " + | ||||||||||
|
||||||||||
| FLog.w(ReactConstants.TAG, | |
| "getChildDrawingOrder index out of bounds! please check your operations of addding and " + | |
| FLog.w(ReactConstants.TAG, | |
| "getChildDrawingOrder index out of bounds! Please check any costom view manipulations you may have done. childCount = %d, index = %d", ..) |
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.
FLog takes a format string. Let's also not make this too verbose, you can always attach a debugger to inspect the full state.
done
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.
Is this ever expected to happen under normal conditions? Can we log a warning here that
mDrawingOrderIndicesis out-of-sync?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.
It will not happen under normal circumstances, but it is not ruled out that some third-party components may add or remove subview in the working thread.