Crash on Motorola G30 but works on Motorola play G9 ?
Opened this issue · 2 comments
Hi,
I'm facing a crash with the toolkit in my app on one specific smartphone, not the other.
Before i was using Renderscript to convert yuv in rgb, and it was working well for a year on : Motorola G9 and Motorola G30
final RenderScript rs = RenderScript.create(this.applicationContext);
final Bitmap bitmap = Bitmap.createBitmap(analyseImageNv21.width, analyseImageNv21.height, Bitmap.Config.ARGB_8888);
final Allocation allocationRgb = Allocation.createFromBitmap(rs, bitmap);
final Allocation allocationYuv = Allocation.createSized(rs, Element.U8(rs), analyseImageNv21.nv21.length);
allocationYuv.copyFrom(analyseImageNv21.nv21);
ScriptIntrinsicYuvToRGB scriptYuvToRgb = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));
scriptYuvToRgb.setInput(allocationYuv);
scriptYuvToRgb.forEach(allocationRgb);
allocationRgb.copyTo(bitmap);
allocationYuv.destroy();
allocationRgb.destroy();
rs.destroy();
return bitmap;
AnalyseImageNv21 is just a simple POJO holding a NV21 format image
public class AnalyseImageNv21 {
public byte[] nv21;
public int width;
public int height;
}
Now I import the renderscript-toolkit module, with the following code
return Toolkit.INSTANCE.yuvToRgbBitmap(analyseImageNv21.nv21, analyseImageNv21.width, analyseImageNv21.height, YuvFormat.NV21);
It works well on motorola G9 Play, but crash on motorola G30 with theses lines in logcat.
02-26 10:11:14.302 21262 21262 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-26 10:11:14.302 21262 21262 F DEBUG : Build fingerprint: 'motorola/caprip_retailen/caprip:12/S0RCS32.41-10-19-21/adced5-adb6a:user/release-keys'
02-26 10:11:14.302 21262 21262 F DEBUG : Revision: 'pvt'
02-26 10:11:14.302 21262 21262 F DEBUG : ABI: 'arm64'
02-26 10:11:14.302 21262 21262 F DEBUG : Timestamp: 2024-02-26 10:11:13.712196673+0100
02-26 10:11:14.302 21262 21262 F DEBUG : Process uptime: 0s
02-26 10:11:14.302 21262 21262 F DEBUG : Cmdline: com.laposte.bscc.mobiliatri
02-26 10:11:14.302 21262 21262 F DEBUG : pid: 20876, tid: 21259, name: RenderScToolkit >>> com.laposte.bscc.mobiliatri <<<
02-26 10:11:14.302 21262 21262 F DEBUG : uid: 10005
02-26 10:11:14.302 21262 21262 F DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x6f2c2ea000
02-26 10:11:14.302 21262 21262 F DEBUG : x0 b400006f2c2ea000 x1 0000000077d613f4 x2 00000000000007f8 x3 00000000782219f4
02-26 10:11:14.302 21262 21262 F DEBUG : x4 0000000000001070 x5 0000000000004528 x6 00000000ffffffff x7 7f7f7f7f7f7f7f7f
02-26 10:11:14.302 21262 21262 F DEBUG : x8 0000000000000838 x9 0000000077d60b9c x10 000000007822119c x11 000000007822119d
02-26 10:11:14.302 21262 21262 F DEBUG : x12 0000000000001070 x13 0000000077d61c0c x14 0000000077d61c0d x15 0000000000001070
02-26 10:11:14.302 21262 21262 F DEBUG : x16 0000006f61cf6ff0 x17 0000006f61cc79b0 x18 0000006f2c750000 x19 0000000000000940
02-26 10:11:14.302 21262 21262 F DEBUG : x20 0000000000001070 x21 000000000000093f x22 0000000000000838 x23 0000006f37d63ef0
02-26 10:11:14.302 21262 21262 F DEBUG : x24 0000000000000001 x25 000000000000093f x26 0000006f2e3e4ff8 x27 00000000000fc000
02-26 10:11:14.302 21262 21262 F DEBUG : x28 0000006f2e2ec000 x29 0000006f2e3e4b80
02-26 10:11:14.302 21262 21262 F DEBUG : lr 0000006f61cba74c sp 0000006f2e3e4b40 pc 0000006f61cc7b30 pst 0000000020000000
02-26 10:11:14.303 21262 21262 F DEBUG : backtrace:
02-26 10:11:14.303 21262 21262 F DEBUG : #00 pc 0000000000044b30 /data/app/~~cVvc8P2rx3wCZUZM-lA1-w==/com.laposte.bscc.mobiliatri-g-R111V7MZzU7FoITbOvJA==/base.apk!librenderscript-toolkit.so (rsdIntrinsicYuv_K+384) (BuildId: 6e2ec30a534239faea020c0a132cc508217bbfc6)
02-26 10:11:14.303 21262 21262 F DEBUG : #01 pc 0000000000037748 /data/app/~~cVvc8P2rx3wCZUZM-lA1-w==/com.laposte.bscc.mobiliatri-g-R111V7MZzU7FoITbOvJA==/base.apk!librenderscript-toolkit.so (renderscript::YuvToRgbTask::processData(int, unsigned long, unsigned long, unsigned long, unsigned long)+80) (BuildId: 6e2ec30a534239faea020c0a132cc508217bbfc6)
02-26 10:11:14.303 21262 21262 F DEBUG : #02 pc 0000000000036e2c /data/app/~~cVvc8P2rx3wCZUZM-lA1-w==/com.laposte.bscc.mobiliatri-g-R111V7MZzU7FoITbOvJA==/base.apk!librenderscript-toolkit.so (renderscript::TaskProcessor::processTilesOfWork(int, bool)+464) (BuildId: 6e2ec30a534239faea020c0a132cc508217bbfc6)
02-26 10:11:14.303 21262 21262 F DEBUG : #03 pc 00000000000374a4 /data/app/~~cVvc8P2rx3wCZUZM-lA1-w==/com.laposte.bscc.mobiliatri-g-R111V7MZzU7FoITbOvJA==/base.apk!librenderscript-toolkit.so (BuildId: 6e2ec30a534239faea020c0a132cc508217bbfc6)
02-26 10:11:14.303 21262 21262 F DEBUG : #04 pc 00000000000b6a74 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+264) (BuildId: 9eba7d8c708c66b9a276c7f5010c97b3)
02-26 10:11:14.303 21262 21262 F DEBUG : #05 pc 0000000000053310 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: 9eba7d8c708c66b9a276c7f5010c97b3)
Any ideas ?
Hello, .. no clues ?
Error seems to be when calling this external function
extern "C" void rsdIntrinsicYuv_K(void *dst, const uchar *Y, const uchar *uv, uint32_t xstart, size_t xend);
Signal 11 is a segmentation fault, i don't think to have a way in my android java code to detect this before and avoid the call.
Maybe a solution by patching YuvToRgb.cpp ?
A bit of searching pointed me to #6, which might be adapted to work for you as well. I think the problem is that these other YUV types are newer than what the toolkit supports, so you have to convert them to a different format first.