mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Do not crash when event is emitted when ReactInstance is reloaded
Summary: Regression introduced in D71735505 where I tried to ensure fabricEventEmitter was always non-null. Instead log a soft error when this happens, so we don't drop the event silently. Changelog: [Android][Fixed] Fixed crash when event is emitted after instance is shutdown Reviewed By: mdvacca Differential Revision: D71967092 fbshipit-source-id: 990b6414b41a2709d70a6deae38f5aa043203a20
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6877263003
commit
6dd5a838c3
+10
-10
@@ -83,7 +83,7 @@ internal class EventEmitterImpl(
|
||||
logSoftException(
|
||||
TAG,
|
||||
ReactNoCrashSoftException(
|
||||
"Cannot get RCTEventEmitter from Context, no active Catalyst instance!"))
|
||||
"Cannot get RCTEventEmitter without active Catalyst instance!"))
|
||||
}
|
||||
}
|
||||
return legacyEventEmitter
|
||||
@@ -100,15 +100,15 @@ internal class EventEmitterImpl(
|
||||
) {
|
||||
@UIManagerType val uiManagerType = getUIManagerType(targetTag, surfaceId)
|
||||
if (uiManagerType == UIManagerType.FABRIC) {
|
||||
checkNotNull(fabricEventEmitter)
|
||||
.receiveEvent(
|
||||
surfaceId,
|
||||
targetTag,
|
||||
eventName,
|
||||
canCoalesceEvent,
|
||||
customCoalesceKey,
|
||||
params,
|
||||
category)
|
||||
val fabricEventEmitter = fabricEventEmitter
|
||||
if (fabricEventEmitter == null) {
|
||||
logSoftException(
|
||||
TAG,
|
||||
ReactNoCrashSoftException("No fabricEventEmitter registered, cannot dispatch event"))
|
||||
} else {
|
||||
fabricEventEmitter.receiveEvent(
|
||||
surfaceId, targetTag, eventName, canCoalesceEvent, customCoalesceKey, params, category)
|
||||
}
|
||||
} else if (uiManagerType == UIManagerType.LEGACY) {
|
||||
ensureLegacyEventEmitter()?.receiveEvent(targetTag, eventName, params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user