Bug Description
In ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp, the registerNatives() function maps the JNI "disable" method to HermesSamplingProfiler::enable instead of
HermesSamplingProfiler::disable:
void HermesSamplingProfiler::registerNatives() {
javaClassLocal()->registerNatives({
makeNativeMethod("enable", HermesSamplingProfiler::enable),
makeNativeMethod("disable", HermesSamplingProfiler::enable), // should be ::disable
...
});
}
This means calling HermesSamplingProfiler.disable() from Java actually calls enable() again, which can corrupt the sampling profiler state
The fix is a one-line change: HermesSamplingProfiler::enable → HermesSamplingProfiler::disable.
Steps To Reproduce
This is a copy-paste bug visible by code inspection — no runtime reproduction steps needed.
Code example:
The bug is in ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp, line 37:
void HermesSamplingProfiler::registerNatives() {
javaClassLocal()->registerNatives({
makeNativeMethod("enable", HermesSamplingProfiler::enable),
makeNativeMethod("disable", HermesSamplingProfiler::enable), // BUG: should be ::disable
makeNativeMethod(
"dumpSampledTraceToFile",
HermesSamplingProfiler::dumpSampledTraceToFile),
});
}
The Expected Behavior
Calling HermesSamplingProfiler.disable() from Java should invoke HermesSamplingProfiler::disable() in C++, which calls hermesAPI->disableSamplingProfiler() and cleanly stops profiling. Instead, it calls
::enable() again, which corrupts the sampling thread state.
The fix is a one-character change: ::enable → ::disable on line 37.
Bug Description
In
ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp, theregisterNatives()function maps the JNI "disable" method toHermesSamplingProfiler::enableinstead ofHermesSamplingProfiler::disable:This means calling
HermesSamplingProfiler.disable()from Java actually callsenable()again, which can corrupt the sampling profiler stateThe fix is a one-line change:
HermesSamplingProfiler::enable→HermesSamplingProfiler::disable.I have run
gradle cleanand confirmed this bug does not occur with JSCThe issue is reproducible with the latest version of React Native.
Hermes git revision: hermes-2025-07-07-RNv0.81.0-e0fc67142ec0763c6b6153ca2bf96df815539782
React Native version: 0.81.4
OS: Android
Platform: arm64-v8a
Steps To Reproduce
This is a copy-paste bug visible by code inspection — no runtime reproduction steps needed.
Code example:
The bug is in ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp, line 37:
The Expected Behavior
Calling
HermesSamplingProfiler.disable()from Java should invokeHermesSamplingProfiler::disable()in C++, which calls hermesAPI->disableSamplingProfiler()and cleanly stops profiling. Instead, it calls::enable() again, which corrupts the sampling thread state.
The fix is a one-character change: ::enable → ::disable on line 37.