Skip to content

Support coalescing keys in the shared Fabric renderer - #57074

Open
sorinc03 wants to merge 1 commit into
react:mainfrom
sorinc03:fix/android-fabric-event-coalescing-key
Open

sorinc03 wants to merge 1 commit into
react:mainfrom
sorinc03:fix/android-fabric-event-coalescing-key

Conversation

@sorinc03

@sorinc03 sorinc03 commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 1 of the split requested in review; related to #54635. This PR now contains shared renderer support only, not Android adoption.

  • Store a coalescing key on RawEvent and require matching target, event type, and key before replacing an event.
  • Keep existing EventEmitter callers on RawEvent::DefaultCoalescingKey (0). The default is an ordinary key, not a wildcard.
  • Add explicit-key EventEmitter overloads for platform integrations without changing existing callers.
  • Add C++ regression cases for matching/different keys, default/custom keys, and interleaved-key ordering.

Rebased onto upstream 9c7b0f5. Android integration is the separate dependent draft #59626; this core change alone does not fix the Android reporting path.

Changelog

[INTERNAL] [CHANGED] - Add custom coalescing-key support to shared Fabric renderer events

Test Plan

  • git diff --check origin/main..HEAD: passed.
  • node scripts/clang-format.js --check <changed C++ files>: passed.
  • Public C++ API snapshots were regenerated with CI-pinned Doxygen 1.16.1 before the clean rebase.
  • Added EventQueueCoalescingTest cases in EventQueueProcessorTest.cpp. These C++ GTests have not been executed locally; native CI verification is pending.

The 18 passing Android integration tests belong to the separate Android follow-up, not this renderer-only revision.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 4, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 4, 2026

@javache javache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I think it would be good to split this in two changes: one that adds support to react/renderer/core and one that adopts in the Android integration.

Comment on lines +85 to +87
fun dispatchUnique(eventName: String, params: WritableMap?, eventTimestamp: Long) {
dispatchUnique(eventName, params, eventTimestamp, 0)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is internal - we don't need to do overloads or keep the API compatible, let's just make sure we update all the callers.

@sorinc03 sorinc03 Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in the now-published Android follow-up #59626 (fe48881): removed the compatibility overload from internal EventEmitterWrapper and updated every dispatchUnique caller, including pending view events and test expectations. The 17 event-ordering tests and 1 emitter-forwarding test pass on the rebased commit. Full JNI/device verification is still pending; the follow-up is draft and depends on the renderer-only revision in this PR. The earlier fork publishing blocker is resolved.

// queue.
if (it->isUnique && it->type == rawEvent.type) {
if (it->isUnique && it->type == rawEvent.type &&
it->coalescingKey == rawEvent.coalescingKey) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this account for RawEvent::DefaultCoalescingKey?

@sorinc03 sorinc03 Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published in the renderer-only revision bc06bf5. RawEvent::DefaultCoalescingKey is the ordinary key 0, not a wildcard: default/default events preserve existing coalescing behavior, while a default-key event and a different custom-key event remain separate. Added C++ cases for both plus interleaved-key ordering. Those renderer GTests have not been executed locally; native CI is pending. The 18 passing local Android tests apply to the separate dependent follow-up #59626, not these C++ tests.

@sorinc03
sorinc03 marked this pull request as draft October 29, 2026 13:42
@sorinc03

sorinc03 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

The fork lock is cleared and the requested split is now published on current upstream main 9c7b0f5:

  1. This PR is renderer-only at bc06bf5: RawEvent key storage, matching target/type/key coalescing, compatible EventEmitter entry points, and explicit default/custom-key and ordering coverage. Existing callers use DefaultCoalescingKey (0), not a wildcard.
  2. Android adoption is the separate dependent draft Adopt renderer coalescing keys in Android Fabric #59626 (fe48881), including the internal EventEmitterWrapper signature cleanup and key forwarding through pending events/JNI. It is stacked on this core change until the dependency lands.

Re-ran the Android follow-up suites: 17 event-ordering tests plus 1 emitter-forwarding test passed, 0 failures/errors. Changed Kotlin/C++ formatting and diff checks pass. C++ API snapshots were regenerated with CI-pinned Doxygen 1.16.1 before the clean rebase. Renderer GTests and full JNI/device verification have not been run locally; current native CI is pending.

This renderer PR is ready for re-review. The Android draft will need rebasing after the renderer change is imported.

@sorinc03
sorinc03 force-pushed the fix/android-fabric-event-coalescing-key branch from 4635137 to bc06bf5 Compare October 29, 2026 15:09
@sorinc03 sorinc03 changed the title Respect Android Fabric event coalescing keys Support coalescing keys in the shared Fabric renderer Oct 29, 2026
@sorinc03
sorinc03 marked this pull request as ready for review October 29, 2026 15:10
@sorinc03

Copy link
Copy Markdown
Contributor Author

@javache The requested split is now published: this PR is renderer-only at bc06bf5, and Android adoption is the dependent draft #59626. The internal overload and DefaultCoalescingKey replies are updated in their threads. This core PR is ready for re-review; native CI is running, and the description distinguishes the added-but-unrun renderer GTests from the 18 passing Android follow-up tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants