From 43f042eb7db0fe97265e05ff39a7af6781530680 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 20 Aug 2019 22:26:57 -0700 Subject: [PATCH] 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 --- .../java/com/facebook/react/devsupport/RedBoxDialog.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxDialog.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxDialog.java index bf509d33455..22e50da0f6c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxDialog.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxDialog.java @@ -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 ? "" : mTitle); + title.setText(titleSafe.replaceAll("\\x1b\\[[0-9;]*m", "")); return title; } else { if (convertView == null) {