When surface is stopped, reset View ID of ReactRootView
Summary: If there's a JS/native crash and the surface is stopped, the ReactRootView could be reused when the surface is restarted (or potentially to show the errors in a logbox; I'm don't think that's possible, but not 100% sure). Regardless, now it will crash in those cases because of T83802049. There's no reason to do that, so just mark the ReactRootView as explicitly unused once the surface is stopped. Changelog: [Internal] Reviewed By: ShikaSD Differential Revision: D26469742 fbshipit-source-id: ee79c094393a8ae8b5c53f04c14b90bc8e1a5a17
This commit is contained in:
Родитель
6a9bb45e09
Коммит
3357341347
|
@ -511,18 +511,23 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
|||
UIManager uiManager =
|
||||
UIManagerHelper.getUIManager(reactApplicationContext, getUIManagerType());
|
||||
if (uiManager != null) {
|
||||
// TODO T48186892: remove when resolved
|
||||
FLog.e(
|
||||
TAG,
|
||||
"stopSurface for surfaceId: " + this.getId(),
|
||||
new RuntimeException("unmountReactApplication"));
|
||||
if (getId() == NO_ID) {
|
||||
final int surfaceId = this.getId();
|
||||
|
||||
// In case of "retry" or error dialogues being shown, this ReactRootView could be
|
||||
// reused (with the same surfaceId, or a different one). Ensure the ReactRootView
|
||||
// is marked as unused in case of that.
|
||||
setId(NO_ID);
|
||||
|
||||
// Remove all children from ReactRootView
|
||||
removeAllViews();
|
||||
|
||||
if (surfaceId == NO_ID) {
|
||||
ReactSoftException.logSoftException(
|
||||
TAG,
|
||||
new RuntimeException(
|
||||
"unmountReactApplication called on ReactRootView with invalid id"));
|
||||
} else {
|
||||
uiManager.stopSurface(this.getId());
|
||||
uiManager.stopSurface(surfaceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче