Work around crashing redbox

Summary: When debugging supporting a Fabric component, a redbox was being shown without a title which resulted in an infinite redbox loop, followed by OOM. That isn't helpful so we just safely work around the null title while indicating what happened to aid in debugging.

Reviewed By: lunaleaps

Differential Revision: D16921053

fbshipit-source-id: df1f4a691df0c10de53c91e4a9356a04a9005a97
This commit is contained in:
Joshua Gross
2019-08-20 22:26:57 -07:00
committed by Facebook Github Bot
parent b8d6ef3726
commit 43f042eb7d
@@ -122,6 +122,8 @@ import org.json.JSONObject;
public StackAdapter(String title, StackFrame[] stack) {
mTitle = title;
mStack = stack;
Assertions.assertNotNull(mTitle);
Assertions.assertNotNull(mStack);
}
@Override
@@ -169,7 +171,8 @@ import org.json.JSONObject;
LayoutInflater.from(parent.getContext())
.inflate(R.layout.redbox_item_title, parent, false);
// Remove ANSI color codes from the title
title.setText(mTitle.replaceAll("\\x1b\\[[0-9;]*m", ""));
String titleSafe = (mTitle == null ? "<unknown title>" : mTitle);
title.setText(titleSafe.replaceAll("\\x1b\\[[0-9;]*m", ""));
return title;
} else {
if (convertView == null) {