Fail safely if there are extra DrawView commands in ClippingDrawCommandManager
Reviewed By: ahmedre Differential Revision: D4525823 fbshipit-source-id: ebae2fe813f86b33a4ede3d42a9968a05f4bb451
This commit is contained in:
parent
14dc219810
commit
be5235f86d
|
@ -5,6 +5,7 @@ android_library(
|
|||
srcs = glob(['*.java']),
|
||||
deps = [
|
||||
YOGA_TARGET,
|
||||
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fbcore'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fresco-drawee'),
|
||||
react_native_dep('libraries/fresco/fresco-react-native:fresco-react-native'),
|
||||
|
@ -32,4 +33,3 @@ android_library(
|
|||
'PUBLIC',
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ package com.facebook.react.flat;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
|
@ -20,6 +21,7 @@ import android.util.SparseIntArray;
|
|||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.uimanager.ReactClippingViewGroup;
|
||||
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
|
||||
|
@ -144,6 +146,9 @@ import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
|
|||
* loosely sorted as well when clipping.
|
||||
*/
|
||||
/* package */ abstract class ClippingDrawCommandManager extends DrawCommandManager {
|
||||
|
||||
private static final String TAG = ClippingDrawCommandManager.class.getSimpleName();
|
||||
|
||||
private final FlatViewGroup mFlatViewGroup;
|
||||
private DrawCommand[] mDrawCommands = DrawCommand.EMPTY_ARRAY;
|
||||
protected float[] mCommandMaxBottom = StateBuilder.EMPTY_FLOAT_ARRAY;
|
||||
|
@ -616,7 +621,17 @@ import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
|
|||
// If we get here, it means we have drawn all the views, now just draw the remaining draw
|
||||
// commands.
|
||||
while (commandIndex < mStop) {
|
||||
mDrawCommands[commandIndex++].draw(mFlatViewGroup, canvas);
|
||||
DrawCommand command = mDrawCommands[commandIndex++];
|
||||
if (command instanceof DrawView) {
|
||||
// We should never have more DrawView commands at this point. But in case we do, fail safely
|
||||
// by ignoring the DrawView command
|
||||
FLog.w(
|
||||
TAG,
|
||||
"Unexpected DrawView command at index " + (commandIndex-1) + " with mStop=" +
|
||||
mStop + ". " + Arrays.toString(mDrawCommands));
|
||||
continue;
|
||||
}
|
||||
command.draw(mFlatViewGroup, canvas);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue