Repository navigation
[0.77][Android] Memory Profiling not working, causing dev tools to disconnect #49158
Description
Activity
- addedDebuggingIssues related to React Native DevTools or legacy JavaScript/Hermes debuggingIssues related to React Native DevTools or legacy JavaScript/Hermes debugging
on Feb 4, 2025 - addedNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.
on Feb 4, 2025 Warning
Missing reproducer: 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/upgrade related: a project using our Reproducer Template
- Otherwise send us a Pull Request with the RNTesterPlayground.js edited to reproduce your bug.
Hi @Kartik4152!
- This looks valid, but I need more info / a reproducer. (Can you confirm this is an empty new Expo app, and what command was used to create?)
- Ideally, I need the content of the failed Heap Snapshot in your app — this can be done by enabling the Protocol Monitor (link to a guide + how to download all messages).
Pointer (for maintainers): Stack trace appears to be one of the
.lengthreads inHeapSnapshot#initialize.- changed the title
[-]Memory Profiling not working, causing dev tools to disconnect[/-][+][0.77][Android] Memory Profiling not working, causing dev tools to disconnect[/+]on Feb 4, 2025 Same exact issue on 0.76.x.
This is not an empty Expo app in our case, but identical issue.
Hermes with newArch.
plus 1 here, not an empty expo app
getting "An error occurred when a call to method 'buildSnapshot' was requested"
andTypeError: Cannot read properties of undefined (reading 'length') at b.initialize (http://127.0.0.1:8081/debugger-frontend/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:13359) at new b (http://127.0.0.1:8081/debugger-frontend/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:33684) at A.buildSnapshot (http://127.0.0.1:8081/debugger-frontend/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:43578) at HeapSnapshotWorkerDispatcher.dispatchMessage (http://127.0.0.1:8081/debugger-frontend/entrypoints/heap_snapshot_worker/heap_snapshot_worker.js:1:47247)in my case it's during first or second snapshot recording. Somewhere at stage "loading edges"
The same goes for "Allocation ..."Reacted by Nantris and SivaShankarI ran into the same issue on a relatively barebones ignite app using expo, hermes, and new arch (RN v0.76.7). I was able to reproduce with a bare expo app upgraded to RN 0.77.1, but I ran into other issues that may be confounding, so I didn't pursue that further.
For what it's worth, here is the Protocol Monitor output (compressed to be small enough to upload here): ProtocolMonitor-20250307T101248.json.zip
Reacted by Nantris, Alex Hunt and SivaShankarGetting the same error in version 0.76.7
Reacted by Ian K, SivaShankar and Taha AlizadehThis issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
27 remaining items
- added and removedNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.
on Oct 13, 2025 Fixed in react/react-native-devtools-frontend#211.
This fix will be available in React Native 0.83. Unfortunately it will be too complicated to pick into older versions of React Native.
Reacted by Nantris, Silas J. Matson and Seph SolimanIf you really want to apply the fix locally on older versions, edit the file
node_modules/@react-native/debugger-frontend/dist/third-party/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker.jsfrom:
async buildSnapshot(e){this.#me=this.#me||{}to:
async buildSnapshot(e){await this.parsingComplete,this.#me=this.#me||{}Reacted by Nantris and Silas J. MatsonReacted by Matt V, Szymon Chęciński, tan5166, Joshua Stupplebeen, Cícero Mello and Tushar GoelFixed in facebook/react-native-devtools-frontend#211.
This fix will be available in React Native 0.83. Unfortunately it will be too complicated to pick into older versions of React Native.
Thank you for the fix. However, fixing older versions should also be prioritized. As we all know, projects based on React Native don't easily upgrade latest minor versions (such as from 0.78 to 0.79) in a short period of time. This is because minor upgrades in React Native often bring about disruptive changes to the community ecosystem. Many projects cannot immediately upgrade to the latest 0.83. In fact, many popular third-party libraries in the React Native ecosystem cannot do so either.
Reacted by SimpleCreationsFixing older versions should also be prioritized.
I totally get the inconvenience, but this is quite a lot of work for us, that we prefer to invest into making the latest versions better. If I choose to pick this, I'd need to actually pick the change into all these older versions, build, throughly test, and then release each of them separately. That process is pretty long.
This does not fall within our pick requests policy. It's not a core feature, not a regression, and there's a workaround I described two comments above that would allow you to enable it using a patch on
node_modules/@react-native/debugger-frontend, say usingpatch-package.Again- not ideal, but this is a matter of prioritization.
Reacted by NantrisFixing older versions should also be prioritized.
I totally get the inconvenience, but this is quite a lot of work for us, that we prefer to invest into making the latest versions better. If I choose to pick this, I'd need to actually pick the change into all these older versions, build each, throughly test each, and then release it. That process is pretty long.
This does not fall within our pick requests policy. It's not a core feature, not a regression, and there's a workaround I described two comments above that would allow you to enable it using a patch on
node_modules/@react-native/debugger-frontend, say usingpatch-package.Again- not ideal, but this is a matter of prioritization.
I understand the heavy workload you're undertaking, and I hope to avoid adding any extra burden. I'd be willing to patch it if possible (in fact, I've already tried, but it didn't work). However, the workaround you provided seems to only work for the more demanding version. I'm currently using RN 0.77, and the code structure in its corresponding
node_modules/@react-native/debugger-frontendpackage is slightly different from the patch results you provided. For example, in version 0.77,buildSnapshotis not an asynchronous function, and the entire file lacks a callablethisparsingCompletefunction. Furthermore, in 0.77, the code snippet forbuildSnapshotisthis.#he=this.#he||{}instead ofthis.#me=this.#me||{}.If convenient, I would also appreciate a patch for 0.77.
Reacted by Cameron Chisholmthe code structure in its corresponding
node_modules/@react-native/debugger-frontendpackage is slightly differentThis is yet another reason not to fix it in older versions- the fix might be different, so it will be demanding more time, and more testing before releasing.
I did look at the code. The patch in that version should also include adding:
this.parsingComplete = this.#ge()to the constructor where
this.#ge()is called.the code structure in its corresponding
node_modules/@react-native/debugger-frontendpackage is slightly differentThis is yet another reason not to fix it in older versions- the fix might be different, so it will be demanding more time, and more testing before releasing.
I did look at the code. The patch in that version should also include adding:
this.parsingComplete = this.#ge()to the constructor where
this.#ge()is called.This made no difference for me on
0.77.3- I assumebuildSnapshot()not being async is probably causing an issue as wellthe code structure in its corresponding
node_modules/@react-native/debugger-frontendpackage is slightly differentThis is yet another reason not to fix it in older versions- the fix might be different, so it will be demanding more time, and more testing before releasing.
I did look at the code. The patch in that version should also include adding:
this.parsingComplete = this.#ge()to the constructor where
this.#ge()is called.This patch is ineffective. I located the issue by setting breakpoints, and the error in the debugger's JavaScript code isn't actually caused by a problem within this function. Instead, it stems from a mismatch between the format of the reported data and the debugger's JavaScript's internal expectations. The debugger's JavaScript is attempting to access the first element of an empty array (i.e., the list's value is
[], but the program is trying to accesslist[0][0]). You can almost always reproduce this problem when using react-native 0.77.3, opening its accompanying devtools, and attempting to record a heap snapshot.Of course, based on your team's previous replies, I understand that you won't spend time reproducing this problem (let alone fixing it). Therefore, you relied on your imagination, slightly modifying a patch applicable to 0.82.x, and used it to reply to us. I think this is inappropriate, but we have no way to address it.
In the near future, we might try to debug the @react-native/debugger-frontend corresponding to react-native 0.77.3 ourselves and fix it.
I also encountered the same issue. Yes, upgrading to newer versions is very troublesome for complex projects. For those, there is an alternative approach. Hermes engine exposes a method to take a heap snapshot: https://github.com/facebook/hermes/blob/static_h/doc/MemoryProfilers.md#taking-a-heap-snapshot-from-c
On my side, I created a method that subscribes a key event and this method generates a temp file. Then, invoke the key event such as
adb shell input keyevent 129which would eventually call Hermes method via fb jsi runtime..#include <jsi/instrumentation.h> // invoke the method on js thread like (invoker->invokeAsync). rt.instrumentation().createSnapshotToFile("/tmp/filename.heapsnapshot");eventually download the file from Android Studio device explorer. Since you do not need to run dev tools, collecting heap snapshot is even more accurate. Unfortunately, you can run this method on debug mode only. It is not supported for release version Hermes engine.
The patch you provided is not working for react-native : 0.79.6. Can you please provide the correct patch for this?
The patch you provided is not working for react-native : 0.79.6. Can you please provide the correct patch for this?
The fix for these versions seems to be totally different.
Since it's very time consuming to even prepare a working environment for such an old version to find the fix, the team will not be doing that.
Consider @SemihGk's workaround one comment above, or maybe somehow involve AI to find a patch based on the fix for version 0.83.
Reacted by Nantris

Description
Hi folks,
I've been trying to profile my apps memory usage using React Native DevTools but anytime I try to take a heap snapshot I get the following error:
This issue is not isolated to my android device, other people on my team are facing the same issue using other android devices and even on emulator.
Steps to reproduce
Take SnapshotReact Native Version
0.77.0
Output of
npx react-native infoScreenshots and Videos
Screen.Recording.2025-02-04.at.3.13.00.PM.mov