Skip to content

Commit

Permalink
][Fabric] Simplify init, always create new EventEmitter for Fabric
Browse files Browse the repository at this point in the history
Summary:
Always create a new EventEmitter specifically for Fabric when initializing the Fabric JSI module.

Previously, we were (sometimes!) reusing the EventEmitter being used for the old renderer and they were shared. There doesn't seem to be a compelling reason to continue doing this, and Fabric has optimized EventEmitters that we can use instead.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29724537

fbshipit-source-id: 1b2c7a7d656e3fb86ddf98a6cf0f2e67dcbf8aef
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Jul 16, 2021
1 parent 2b7366e commit 4f38cb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@

package com.facebook.react.fabric;

import static com.facebook.react.config.ReactFeatureFlags.enableExperimentalStaticViewConfigs;

import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSIModuleProvider;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.common.mapbuffer.ReadableMapBufferSoLoader;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.fabric.events.EventBeatManager;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManagerRegistry;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace;

public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {
Expand Down Expand Up @@ -77,18 +73,8 @@ private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManag
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager");

FabricUIManager fabricUIManager;
if (enableExperimentalStaticViewConfigs) {
fabricUIManager =
new FabricUIManager(mReactApplicationContext, mViewManagerRegistry, eventBeatManager);
} else {
// TODO T83943316: Remove this code once StaticViewConfigs are enabled by default
UIManagerModule nativeModule =
Assertions.assertNotNull(mReactApplicationContext.getNativeModule(UIManagerModule.class));
EventDispatcher eventDispatcher = nativeModule.getEventDispatcher();
fabricUIManager =
new FabricUIManager(
mReactApplicationContext, mViewManagerRegistry, eventDispatcher, eventBeatManager);
}
fabricUIManager =
new FabricUIManager(mReactApplicationContext, mViewManagerRegistry, eventBeatManager);
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
return fabricUIManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void executeItems(Queue<MountItem> items) {

// TODO T83943316: Deprecate and delete this constructor once StaticViewConfigs are enabled by
// default
@Deprecated
public FabricUIManager(
ReactApplicationContext reactContext,
ViewManagerRegistry viewManagerRegistry,
Expand Down

0 comments on commit 4f38cb3

Please sign in to comment.