facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.54k stars 24.37k forks source link

MessageQueue.spy not displaying module names on Android release variant #31915

Closed alex-a-pereira closed 8 months ago

alex-a-pereira commented 3 years ago

Description

Hi! I've been trying to debug an issue (not relevant to this bug report) and I've found the MessageQueue.spy method which looks super helpful to debug with. However, when I enable spying on the message queue, integers are used instead of module/function names.

This might be coincidence, but it looks like the issue only exists for messages passed from JS to Native, not the other way around (see screenshot below). So this might be an issue with my babel config or something (see babel config below).

React Native version:

System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Memory: 1.17 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.12.0 - /var/folders/j0/4gxn4f712lb69z62zjqlgr700000gn/T/yarn--1627476735166-0.4344096847464143/node
    Yarn: 1.22.10 - /var/folders/j0/4gxn4f712lb69z62zjqlgr700000gn/T/yarn--1627476735166-0.4344096847464143/yarn
    npm: 7.6.3 - ~/.nvm/versions/node/v15.12.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 26, 27, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6858069
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_272 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: 0.64.0 => 0.64.0
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. add the following code to entry file (index.js in my case)
    import MessageQueue from 'react-native/Libraries/BatchedBridge/MessageQueue.js'
    // rest of file...
    MessageQueue.spy(true)
  2. run the following command to build/install on real device
    yarn android-install-release
    # this runs:
    # adb reverse tcp:8081 tcp:8081 && cd ./android && ./gradlew clean && ./gradlew app:assembleRelease && ./gradlew installRelease
  3. run adb logcat (or use a GUI like I'm doing, I'm using logRabbit) to view logs - grep for your application name
  4. open up the app on your device after the build is assembled/installed

Expected Results

We expect that native modules/method names are displayed in logs similar to as described here. The format is a bit different as I passed in true instead of a callback function to MessageQueue.spy - but I've validated that module/method names are missing when passing a callback function as well.

Snack, code example, screenshot, or link to a repository:

Here's a screenshot of my logs image

Note that the first log AppRegistry.runApplication is in correct format (direction is from native to JS). But the bottom two are calls from JS->native and have integers for the module/method.

Babel Config

// babel.config.js in root of project
module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    ['module-resolver', {
      alias: {
        '@components': './src/components',
        '@screens': './src/screens',
        '@layouts': './src/layouts',
        '@services': './src/services',
        '@store': './src/store',
        '@setup': './src/setup',
        '@utils': './src/utils',
        '@reactHooks': './src/reactHooks',
        '@assets': './assets',
        '@apiQueries': './src/apiQueries',
        '@apiRequests': './src/apiRequests',
        '@reactContext': './src/reactContext',
        '@_dev': ['./src/_dev']
      }
    }]
  ]
}
github-actions[bot] commented 8 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 8 months ago

This issue was closed because it has been stalled for 7 days with no activity.