mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Throw non-crashing SoftException when ViewCommand is sent to non-existent tag
Summary: Motivation: TextInput.js frequently sends commands to views as they're disappearing (`blur`, for instance). We should fix that in the future, if possible. For now, just log the issue and continue. It shouldn't cause any user-facing issues since 1) it appears that TextInput knows the underlying view is gone; 2) the View has already disappeared so the user can't interact with it, so commands can go safely into the void. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D18821448 fbshipit-source-id: 980dbbce8cdb2cc0bb4bf60b3bccc90869208f01
This commit is contained in:
committed by
Facebook Github Bot
parent
5ff82b7094
commit
48c69af3e0
@@ -20,6 +20,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.infer.annotation.ThreadConfined;
|
||||
import com.facebook.react.bridge.ReactNoCrashSoftException;
|
||||
import com.facebook.react.bridge.ReactSoftException;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
@@ -138,10 +139,15 @@ public class MountingManager {
|
||||
public void receiveCommand(int reactTag, int commandId, @Nullable ReadableArray commandArgs) {
|
||||
ViewState viewState = getNullableViewState(reactTag);
|
||||
|
||||
// It's not uncommon for JS to send events as/after a component is being removed from the
|
||||
// view hierarchy. For example, TextInput may send a "blur" command in response to the view
|
||||
// disappearing. Throw `ReactNoCrashSoftException` so they're logged but don't crash in dev
|
||||
// for now.
|
||||
// TODO T58653970: Crash in debug again and fix all the places that cause this to crash.
|
||||
if (viewState == null) {
|
||||
ReactSoftException.logSoftException(
|
||||
MountingManager.TAG,
|
||||
new IllegalStateException(
|
||||
new ReactNoCrashSoftException(
|
||||
"Unable to find viewState for tag: " + reactTag + " for commandId: " + commandId));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user