Skip to content

Commit

Permalink
Fix event emits during initial rendering in Fabric (facebook#42777)
Browse files Browse the repository at this point in the history
Summary:

During view preallocation eventEmitter information is not being passed to the platform. This causes bugs with emision of events during initial rendering when using the new Fabric Event dispatching system.

e.g. Rendering a TextInput that has 'onFocus' event and also has autoFocus enabled.

The new Fabric Event dispatching system dispatch events earlier (this is expected)

In this diff I'm fixing this issue by ensuring that all preallocated views have an eventEmitter (when its shadowNode has an eventEmitter)

This was actually implemented in the past, but in order to optimize, we run an experiment (D29117957) and it was later deleted.
(D40356386). I didn't find details of the results of the experiment.
We could run another experiment to understand potential negative perf impact of this change, although I believe it's the right thing to do here.


Changelog: [Android][Fixed] Fix delivery of events during initial rendering in new architecture

Reviewed By: sammy-SC

Differential Revision: D53108114
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 1, 2024
1 parent ebc2831 commit d1df911
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public float getEffectiveMaxFontSizeMultiplier() {
: DEFAULT_MAX_FONT_SIZE_MULTIPLIER;
}

@Override
public String toString() {
return ("TextAttributes {"
+ "\n getAllowFontScaling(): "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,11 @@ void FabricMountingManager::preallocateShadowView(

// Do not hold a reference to javaEventEmitter from the C++ side.
jni::local_ref<EventEmitterWrapper::JavaPart> javaEventEmitter = nullptr;
SharedEventEmitter eventEmitter = shadowView.eventEmitter;
if (eventEmitter != nullptr) {
javaEventEmitter =
EventEmitterWrapper::newObjectCxxArgs(shadowView.eventEmitter);
}

jni::local_ref<jobject> props = getProps({}, shadowView);

Expand Down

0 comments on commit d1df911

Please sign in to comment.