Crash in libmedia_jni.so when using MediaCodec callback with DJI SDK
We’re encountering a native crash while using DJI Mobile SDK together with Android’s MediaCodec API for video decoding. The crash occurs inside libmedia_jni.so during the callback handling.
Backtrace:
#06 pc ... /system/lib64/libmedia_jni.so (android::JMediaCodec::handleCallback(android::sp<android::AMessage> const&)+524)
#04 pc ... /apex/com.android.art/lib64/libart.so (art::JNI<false>::FindClass+696)
#00 pc ... /apex/com.android.runtime/lib64/bionic/libc.so (abort+164)
...
It looks like a FindClass call from native code is failing during a MediaCodec callback, which causes an abort in ART runtime.
Steps:
- We are using MediaCodec.setCallback(...) with a custom HandlerThread.
- The crash occurs intermittently during video playback/streaming via DJI SDK.
Questions: 1. Is DJI SDK internally using MediaCodec or handling JMediaCodec callbacks that may conflict with app-level MediaCodec usage? 2. Are there known limitations or conflicts when using MediaCodec callbacks in background threads? 3. What’s the recommended way to safely integrate custom MediaCodec usage alongside DJI’s video pipeline?
We appreciate any suggestions or guidance to prevent this crash.
Agent comment from YIGUI LIU in Zendesk ticket #141740:
Dear Developer,
After confirming with the R&D team of DJI MSDK, MSDK will not conflict with your use of the Android's MediaCodec API. It is possible that the error you encountered is caused by the insufficient performance of an older remote controller.
What kind of encoded video stream are you mainly trying to obtain by using MediaCodec? MSDK provides video streams in some encoding formats, and you can refer to the documentation:
- How to get the stanard H.264 video stream from M300?:https://sdk-forum.dji.net/hc/en-us/articles/4404231981465-How-to-get-the-stanard-H-264-video-stream-from-M300
- How to get Yuv data video stream? :https://sdk-forum.dji.net/hc/en-us/articles/900006791123-How-to-get-Yuv-data-video-stream
- How to obtain the video stream data of the camera and display the camera image? :https://sdk-forum.dji.net/hc/en-us/articles/30040327006233-How-to-obtain-the-video-stream-data-of-the-camera-and-display-the-camera-image
Best Regards,
DJI Innovations SDK Technical Support Team
°°°
We're encountering a crash when calling com.cySdkyc.clx.Helper.install(this) inside Application.attachBaseContext().
From the log, the crash occurs specifically during native library loading:
This suggests that either the required native .so library is missing or not loaded properly at that time.
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
com.cySdkyc.clx.Helper.install(this)
}
Agent comment from YIGUI LIU in Zendesk ticket #141740:
Dear Developer,
Hello and thank you for reaching out to DJI Innovations.
The MSDK R&D team has checked the logs you provided and fed back that it has nothing to do with the MSDK. It is likely related to the insufficient performance of the remote controller itself, which has led to a memory overflow.
Due to the performance limitations of the old model remote controller, there is currently no good solution. You can upgrade the firmware version of the remote controller or continuously debug and optimize the code.
We appreciate your email and wish you a wonderful day!
Best Regards,
DJI Innovations SDK Technical Support Team
°°°