react / react/react-native

[Android] Incorrect handling of coalescingKey

オープン
#54,635 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Issue: Author Provided Repro Needs: React Native Team Attention
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

In the CustomNativeComponentNativeLayoutEvent class, I’m providing a unique coalescingKey per event:

class CustomNativeComponentNativeLayoutEvent(
    surfaceId: Int,
    viewId: Int,
    val tabBarHeight: Int
) : Event<CustomNativeComponentNativeLayoutEvent>(surfaceId, viewId) {

    override fun getEventName() = EVENT_NAME

    // Our implementation (coalescing is enabled)
    override fun getCoalescingKey(): Short {
        return tabBarHeight.toShort()
    }
}

But in practice, only some events are being received on the JS side. The logs show events being emitted properly from native:

D  emitting from native 914
D  emitting from native 3
D  emitting from native 7
D  emitting from native 11
I  Received tabBarHeight on JS side 914
I  Received tabBarHeight on JS side 11
D  emitting from native 15
D  emitting from native 19
I  Received tabBarHeight on JS side 19
D  emitting from native 22
D  emitting from native 26
D  emitting from native 30
I  Received tabBarHeight on JS side 30
D  emitting from native 34
D  emitting from native 38
I  Received tabBarHeight on JS side 38

I would expect all events to be received since each has a unique coalescingKey.

After a quick investigation, I noticed this part of the code:

https://github.com/facebook/react-native/blob/v0.82.0-rc.5/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.kt#L36-L51

It seems like the coalescingKey is not passed forward. Is this expected behavior? Or should that value be forwarded so that events could be properly distinguished and delivered?

Steps to reproduce
  1. Clone the repo (use the branch from the link) https://github.com/t0maboro/Screens3184/tree/%40t0maboro/issue-1
  2. Run application on android
  3. Observe logs with tag: ReactNativeJS - I used this tag to have native logs filtered together with console.log from JS
React Native Version

0.82.1

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.6.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 101.11 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.3.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.4.2
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2025.09.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.0
      - iOS 26.0
      - macOS 26.0
      - tvOS 26.0
      - visionOS 26.0
      - watchOS 26.0
  Android SDK:
    API Levels:
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 34.0.0
      - 35.0.0
      - 36.0.0
      - 36.1.0
      - 36.1.0
    System Images:
      - android-25 | Google APIs ARM 64 v8a
      - android-27 | Google APIs ARM 64 v8a
      - android-28 | Google APIs ARM 64 v8a
      - android-29 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13840223
  Xcode:
    version: 26.0.1/17A400
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.15
    path: /usr/bin/javac
  Ruby:
    version: 3.4.2
    path: /Users/tomaszboron/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.1
    wanted: 19.1.1
  react-native:
    installed: 0.82.1
    wanted: 0.82.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false
Stacktrace or Logs
D  emitting from native 914
D  emitting from native 3
D  emitting from native 7
D  emitting from native 11
I  Received tabBarHeight on JS side 914
I  Received tabBarHeight on JS side 11
D  emitting from native 15
D  emitting from native 19
I  Received tabBarHeight on JS side 19
D  emitting from native 22
D  emitting from native 26
D  emitting from native 30
I  Received tabBarHeight on JS side 30
D  emitting from native 34
D  emitting from native 38
I  Received tabBarHeight on JS side 38
MANDATORY Reproducer

https://github.com/t0maboro/Screens3184/tree/%40t0maboro/issue-1

Screenshots and Videos

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンク先の行にある FabricEventEmitter.kt から始め、必須の Screens3184 ブランチを使用して動作を再現します。ネイティブでの発行から JavaScript への配信まで coalescingKey が保持されるかを追跡し、完了した動作で発行されたイベントが期待どおりに区別されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, kotlin
領域
mobile-dev
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。