Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] fix whiteScreen viewTree record && run state history record (
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky-chen authored and YorkShen committed Jun 28, 2019
1 parent 1960291 commit 925a922
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ private void checkWhiteScreen(){
}
WXErrorCode errorCode = WXErrorCode.WX_ERROR_WHITE_SCREEN;
Map<String,String> args = new HashMap<>(1);
String vieTreeMsg = WhiteScreenUtils.getViewMsg(this);
String vieTreeMsg = WhiteScreenUtils.takeViewTreeSnapShot(this);
args.put("viewTree",null == vieTreeMsg?"null viewTreeMsg":vieTreeMsg);

for (Map.Entry<String,String> entry: WXStateRecord.getInstance().getStateInfo().entrySet()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public RecordList(int maxSize) {
@Override
public boolean add(E e) {
if (this.size()>0 && this.size() >= maxSize){
remove(this.size() - 1);
remove(0);
}
return super.add(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,38 +115,16 @@ private static boolean hasLeafViewOrSizeIgnore(View v,int checkDeep) {
/**
* get instance viewTree && component tree msg
*/
public static String getViewMsg(WXSDKInstance instance) {
public static String takeViewTreeSnapShot(WXSDKInstance instance) {
if (null == instance) {
return "nullInstance";
}
View v = instance.getContainerView();
StringBuilder builder = new StringBuilder();
WXComponent component = instance.getRootComponent();
if (null != component) {
builder.append("componentMsg:").append(getComponentTreeMsg(component)).append("-----");
JSONObject root = geViewDetailTreeMsg(v);
if (null != root) {
return root.toString();
}
if (null != v) {
builder.append("viewTreeMsg:").append(geViewDetailTreeMsg(v));
}
return builder.toString();
}

private static String getComponentTreeMsg(WXComponent component) {
if (null == component) {
return "nullComponent";
}

if (!(component instanceof WXVContainer)) {
return component.getRef();
}
WXVContainer container = (WXVContainer)component;
StringBuilder builder = new StringBuilder();
builder.append(" _start_ ");
for (int i = 0; i < container.getChildCount(); i++) {
builder.append(getComponentTreeMsg(container.getChild(i))).append(",");
}
builder.append(" _end_ ");
return builder.toString();
return "";
}

private static JSONObject geViewDetailTreeMsg(View view) {
Expand All @@ -165,10 +143,10 @@ private static JSONObject geViewDetailTreeMsg(View view) {
node.put("y", location[1]);

if (view instanceof ViewGroup) {
node.put("type", "ViewGroup");
node.put("type", view.getClass().getSimpleName());
ViewGroup group = (ViewGroup)view;
for (int i = 0; i < group.getChildCount(); i++) {
node.put("child", geViewDetailTreeMsg(group.getChildAt(i)));
node.put("child_"+i, geViewDetailTreeMsg(group.getChildAt(i)));
}
} else {
node.put("type", view.getClass().getSimpleName());
Expand Down

0 comments on commit 925a922

Please sign in to comment.