Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactEventEmitter null fix #44394

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.facebook.react.fabric.events;

import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
Expand All @@ -34,7 +33,7 @@ public final class EventBeatManager implements BatchEventDispatchedListener {
private native void tick();

@Deprecated(forRemoval = true, since = "Deprecated on v0.72.0 Use EventBeatManager() instead")
public EventBeatManager(@NonNull ReactApplicationContext reactApplicationContext) {
public EventBeatManager(ReactApplicationContext reactApplicationContext) {
this();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
package com.facebook.react.fabric.events;

import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.NativeMap;
Expand All @@ -21,6 +21,7 @@
* This class holds reference to the C++ EventEmitter object. Instances of this class are created in
* FabricMountingManager.cpp, where the pointer to the C++ event emitter is set.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
@DoNotStrip
@SuppressLint("MissingNativeLoadLibrary")
public class EventEmitterWrapper {
Expand All @@ -37,9 +38,9 @@ private EventEmitterWrapper(HybridData hybridData) {
}

private native void dispatchEvent(
@NonNull String eventName, @NonNull NativeMap params, @EventCategoryDef int category);
String eventName, @Nullable NativeMap params, @EventCategoryDef int category);

private native void dispatchUniqueEvent(@NonNull String eventName, @NonNull NativeMap params);
private native void dispatchUniqueEvent(String eventName, @Nullable NativeMap params);

/**
* Invokes the execution of the C++ EventEmitter.
Expand All @@ -48,9 +49,7 @@ private native void dispatchEvent(
* @param params {@link WritableMap} payload of the event
*/
public synchronized void dispatch(
@NonNull String eventName,
@Nullable WritableMap params,
@EventCategoryDef int eventCategory) {
String eventName, @Nullable WritableMap params, @EventCategoryDef int eventCategory) {
if (!isValid()) {
return;
}
Expand All @@ -64,7 +63,7 @@ public synchronized void dispatch(
* @param eventName {@link String} name of the event to execute.
* @param params {@link WritableMap} payload of the event
*/
public synchronized void dispatchUnique(@NonNull String eventName, @Nullable WritableMap params) {
public synchronized void dispatchUnique(String eventName, @Nullable WritableMap params) {
if (!isValid()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package com.facebook.react.fabric.events;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.WritableArray;
Expand All @@ -22,14 +21,14 @@
@Nullsafe(Nullsafe.Mode.LOCAL)
public class FabricEventEmitter implements RCTModernEventEmitter {

@NonNull private final FabricUIManager mUIManager;
private final FabricUIManager mUIManager;

public FabricEventEmitter(@NonNull FabricUIManager uiManager) {
public FabricEventEmitter(FabricUIManager uiManager) {
mUIManager = uiManager;
}

@Override
public void receiveEvent(int reactTag, @NonNull String eventName, @Nullable WritableMap params) {
public void receiveEvent(int reactTag, String eventName, @Nullable WritableMap params) {
receiveEvent(ViewUtil.NO_SURFACE_ID, reactTag, eventName, params);
}

Expand Down Expand Up @@ -61,9 +60,7 @@ public void receiveEvent(
/** Touches are dispatched by {@link #receiveTouches(TouchEvent)} */
@Override
public void receiveTouches(
@NonNull String eventName,
@NonNull WritableArray touches,
@NonNull WritableArray changedIndices) {
String eventName, WritableArray touches, WritableArray changedIndices) {
throw new UnsupportedOperationException(
"EventEmitter#receiveTouches is not supported by Fabric");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ public void receiveEvent(
customCoalesceKey,
event,
category);
} else if (uiManagerType == UIManagerType.DEFAULT && getDefaultEventEmitter() != null) {
mDefaultEventEmitter.receiveEvent(targetReactTag, eventName, event);
} else if (uiManagerType == UIManagerType.DEFAULT) {
RCTEventEmitter defaultEmitter = getDefaultEventEmitter();
if (defaultEmitter != null) {
defaultEmitter.receiveEvent(targetReactTag, eventName, event);
}
} else {
ReactSoftExceptionLogger.logSoftException(
TAG,
Expand Down