FIRST-Tech-Challenge / SkyStone

FTC SDK
https://www.firstinspires.org/robotics/ftc/what-is-first-tech-challenge
273 stars 1.04k forks source link

"renderScript creation failed" - UvcFrame#yuy2ToBitmap() fails on some devices #85

Open Windwoes opened 4 years ago

Windwoes commented 4 years ago

This bug came to my attention through a bug report on my EasyOpenCV library.

On some devices, the SDK's native code which invokes RenderScript in order to handle a call to UvcFrame#yuy2ToBitmap() fails with the following errors:

D/UvcContext: [jni_context.cpp:133] creating renderScript(/data/user/0/com.qualcomm.ftcrobotcontroller/cache/org.firstinspires.ftc.renderscript.cache,0x00000000,26)
E/rsC++: Couldn't initialize dispatch table
E/UvcContext: [jni_context.cpp:141] renderScript initialization failed: err=0
E/UvcFrame: [jni_frame.cpp:226] renderScript creation failed

The error Couldn't initialize dispatch table can be traced to this line in RenderScript.cpp of the AOSP codebase. That appears to indicate that this method, also in RenderScript.cpp is returning false, which in turn seems to indicate that the native library for RenderScript is failing to load.

Strangely, this only affects certain devices:

Known Devices Affected:

Known Devices Not Affected:

Curiously, it was reported that even on these problematic devices, the Vuforia webcam sample worked without issue. This leads me to suspect (though I cannot verify since the C++ source for the native libraries in the SDK has not been released) that jni_frame.cpp does not invoke RenderScript to convert the YUY2 frames to RGB before delivering to Vuforia.

FYI - I was able to fix this issue in EasyOpenCV by using reflection to dump the raw framebuffer into a byte array and then using OpenCV to convert from YUY2 to RGB instead of using UvcFrame#yuy2ToBitmap().

Windwoes commented 3 years ago

This is probably fixed in v5.5, but should be verified