React Native App Crashes Instantly When Entering Debug Mode when using NativeModules & JNI
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 127k
- Forks
- 25.3k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
Description
I've created a small react-native app that uses some custom c++ code and the OpenCV library and works using the JNI and Native Modules. The app works fine however when I try to debug the react native code using the in app developer menu, my app instantly crashes and I get this error in Logcat (Full stack trace in section below):
My custom c++ code only gets called once I hit a button in the app and this crashes out before I even get a chance to press the button, which leads me to believe it's an issue to do with debugging a react-native app when using Custom Modules and JNI.
This happens when I test on both a physical device (Samsung A40) and an emulator (Pixel 3a).
Has anyone encountered an issue like this before or may know what is causing this to happen?
Appreciate any guidance / help on this one.
React Native Version
0.72.0
Output of npx react-native info
System:
OS: Windows 10 10.0.19044
CPU: "(12) x64 AMD Ryzen 5 7600X 6-Core Processor "
Memory: 1.69 GB / 15.15 GB
Binaries:
Node:
version: 18.16.1
path: C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm:
version: 9.5.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-222.4459.24.2221.10121639
Visual Studio:
- 17.6.33815.320 (Visual Studio Community 2022)
Languages:
Java: 11.0.19
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.0
wanted: 0.72.0
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Steps to reproduce
- Create an app that uses Native Modules to call a native method which uses JNI to call a method in c++.
- Run the app in debug mode and open the developer menu
- Select "Debug" from the developer menu
- App instantly crashes
Snack, code example, screenshot, or link to a repository
Link to repository: https://github.com/Matt-Horton/image-processor
23-07-12 10:14:17.986 10985-11040 libc com.imageprocessor A Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 11040 (mqt_js), pid 10985 (.imageprocessor)
2023-07-12 10:14:18.590 11051-11051 DEBUG pid-11051 A Cmdline: com.imageprocessor
2023-07-12 10:14:18.590 11051-11051 DEBUG pid-11051 A pid: 10985, tid: 11040, name: mqt_js >>> com.imageprocessor <<<
2023-07-12 10:14:18.590 11051-11051 DEBUG pid-11051 A #00 pc 000000000003b7f4 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreact_render_runtimescheduler.so (facebook::react::RuntimeSchedulerBinding::createAndInstallIfNeeded(facebook::jsi::Runtime&, std::__ndk1::shared_ptrfacebook::react::RuntimeScheduler const&)+68) (BuildId: 154f261ff589aa1e)
2023-07-12 10:14:18.590 11051-11051 DEBUG pid-11051 A #01 pc 00000000002055e1 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.590 11051-11051 DEBUG pid-11051 A #02 pc 0000000000205591 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.590 11051-11051 DEBUG pid-11051 A #03 pc 0000000000205531 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #04 pc 00000000002054e1 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #05 pc 0000000000204300 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #06 pc 000000000028b3a9 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #07 pc 000000000028ad2c /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (std::__ndk1::function<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const+44) (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #08 pc 000000000028ac68 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #09 pc 000000000028ac11 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #10 pc 000000000028abb1 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #11 pc 000000000028ab61 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #12 pc 0000000000289ab0 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #13 pc 00000000002b56b9 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #14 pc 00000000002b5629 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (std::__ndk1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const+57) (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.591 11051-11051 DEBUG pid-11051 A #15 pc 00000000002b55e6 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #16 pc 00000000002b556c /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #17 pc 00000000002b551c /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #18 pc 00000000002b54ec /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #19 pc 00000000002b43b8 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #20 pc 00000000003e56d1 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libhermes_executor.so (BuildId: 53166c965b19a311)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #21 pc 00000000003e5694 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libhermes_executor.so (std::__ndk1::function<void ()>::operator()() const+20) (BuildId: 53166c965b19a311)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #22 pc 00000000002153c4 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #23 pc 000000000021533c /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #24 pc 00000000002152ec /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #25 pc 00000000002152bc /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.592 11051-11051 DEBUG pid-11051 A #26 pc 0000000000214248 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libreactnativejni.so (BuildId: eedf0b28937d60c0)
2023-07-12 10:14:18.593 11051-11051 DEBUG pid-11051 A #27 pc 0000000000016979 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libfbjni.so (facebook::jni::detail::MethodWrapper<void (facebook::jni::JNativeRunnable::)(), &(facebook::jni::JNativeRunnable::run()), facebook::jni::JNativeRunnable, void>::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject>)+25) (BuildId: 24c51b71e72aa958d98c6f3c2304d6447e26c99e)
2023-07-12 10:14:18.593 11051-11051 DEBUG pid-11051 A #28 pc 00000000000168f4 /data/app/~~iVVShjhaWAgH81QQf8xjPQ==/com.imageprocessor-JBViIjDg9OhWp4uwtsY-7Q==/lib/x86_64/libfbjni.so (facebook::jni::detail::FunctionWrapper<void ()(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject>), facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject*, void>::call(_JNIEnv*, _jobject*, void ()(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::jni::JNativeRunnable, facebook::jni::JRunnable>::JavaPart, facebook::jni::JRunnable, void>::_javaobject>))+52) (BuildId: 24c51b71e72aa958d98c6f3c2304d6447e26c99e)
---------------------------- PROCESS ENDED (10985) for package com.imageprocessor ----------------------------
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the crash in the linked image-processor repository with React Native 0.72.0, using the developer menu's Debug action and capturing Logcat. Inspect the Native Modules and JNI path alongside the RuntimeSchedulerBinding stack frame. Done means identifying the cause and confirming that entering debug mode no longer crashes on the reported device and emulator setups.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, cpp, react-native
- Domain
- computer-vision, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100