Skip to content

Commit 43a0e37

Browse files
committed
fix(Native): resolve freezing issue during app reload in release mode
1 parent 93872ff commit 43a0e37

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void run() {
166166
throw new NoSuchMethodException("ReactDelegate doesn't have reload method in RN < 0.74");
167167
}
168168

169-
resetReactRootViewsIfDebug(instanceManager, reactDelegate);
169+
resetReactRootViews(reactDelegate);
170170

171171
Method reloadMethod = reactDelegate.getClass().getMethod("reload");
172172
reloadMethod.invoke(reactDelegate);
@@ -191,20 +191,17 @@ public void run() {
191191
}
192192
}
193193

194-
// Fix freezing that occurs when reloading the app in debug mode (RN >= 0.77.1 Old Architecture)
194+
// Fix freezing that occurs when reloading the app (RN >= 0.77.1 Old Architecture)
195195
// - "Trying to add a root view with an explicit id (11) already set.
196196
// React Native uses the id field to track react tags and will overwrite this field.
197197
// If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView."
198-
private void resetReactRootViewsIfDebug(ReactInstanceManager instanceManager, ReactDelegate reactDelegate) {
199-
DevSupportManager devSupportManager = instanceManager.getDevSupportManager();
200-
if (devSupportManager.getDevSupportEnabled()) {
201-
ReactActivity currentActivity = (ReactActivity) getCurrentActivity();
202-
if (currentActivity != null) {
203-
ReactRootView reactRootView = reactDelegate.getReactRootView();
204-
if (reactRootView != null) {
205-
reactRootView.removeAllViews();
206-
reactRootView.setId(View.NO_ID);
207-
}
198+
private void resetReactRootViews(ReactDelegate reactDelegate) {
199+
ReactActivity currentActivity = (ReactActivity) getCurrentActivity();
200+
if (currentActivity != null) {
201+
ReactRootView reactRootView = reactDelegate.getReactRootView();
202+
if (reactRootView != null) {
203+
reactRootView.removeAllViews();
204+
reactRootView.setId(View.NO_ID);
208205
}
209206
}
210207
}

0 commit comments

Comments
 (0)