facebook / react-native

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

Heap snapshot throwing `RangeError: Invalid typed array length: -1` on latest chrome version #45582

Closed marmor157 closed 1 month ago

marmor157 commented 3 months ago

Description

Currently when trying to make the heap snapshot in the Chrome DevTools in the Memory tab it throws the error provided in the stacktrace section.

Chrome version: 126.0.6478.183 iOS SImulator: 17.0 iPhone SE 3rd gen Android Emulator: Pixel 7 Android 11.0

The error does not occur on the chrome version 124.0.6367.203 and heap snapshot works there normally.

Steps to reproduce

  1. npx @react-native-community/cli@latest init AwesomeProject
  2. npm start
  3. Open iOS/Android Simulator
  4. Go to chrome://inspect
  5. Open DevTools, experimental debugger or not, doesn't matter
  6. Go to Memory tab
  7. Click Take snapshot at the bottom of the tab

React Native Version

0.74.3 - 0.72.0

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 13.5.2
  CPU: (8) arm64 Apple M1 Pro
  Memory: 100.45 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.5.1
    path: ~/.asdf/installs/nodejs/20.5.1/bin/node
  Yarn: Not Found
  npm:
    version: 9.8.0
    path: ~/.asdf/plugins/nodejs/shims/npm
  Watchman:
    version: 2023.11.20.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 21
    path: /Users/mariuszmorawski/.asdf/shims/javac
  Ruby:
    version: 3.2.2
    path: /Users/mariuszmorawski/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

An error occurred when a call to method 'buildSnapshot' was requested
RangeError: Invalid typed array length: -1
    at new Uint32Array (<anonymous>)
    at F.initialize (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:14793)
    at new F (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:38027)
    at _.buildSnapshot (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:47869)
    at HeapSnapshotWorkerDispatcher.dispatchMessage (devtools://devtools/bundled/devtools-frontend/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:51664)

Reproducer

https://github.com/marmor157/heap-snapshot-crash-repro

Doesn't matter since it happens on barebones app but here you go.

Screenshots and Videos

No response

react-native-bot commented 3 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
react-native-bot commented 3 months ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.72.15. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
react-native-bot commented 3 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
react-native-bot commented 3 months ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
cortinico commented 3 months ago

Can you try on 0.74 as well @marmor157 ?

marmor157 commented 3 months ago

@cortinico Sorry, I've actually tried it on 0.74 but edited it from the description mistakenly. I've tried it on:

huntie commented 3 months ago

Hi @marmor157, you mention this happens in the latest Chrome version. Can you try --experimental-debugger and use j to open that frontend? This method will use a versioned instance of Chrome DevTools, which we've previously tested.

marmor157 commented 3 months ago

@huntie Just tested it on 0.74.3 and it works with the experimental debugger opened by pressing j.