android - Memory errors using Allocations and RenderScript -


i working on live streaming wifi camera android tablet. have frame grabber running in thread, in turn takes pixels , passes them renderscript filter processing (another thread). output allocation linked surface viewing.

the app crash periodically sigsegv faults, monitor says it's happening in either thread, gcdaemon or jnisurfacetexture. have 2 kernels running (switchable) , both fail eventually. more basic kernel pixel [] camera input allocation, sent renderscript , result output allocation of 'foreach' call sent surface using .iosend().

if take pixel [] array camera thread , copy directly output allocation, , call .iosend(), never crashes (i.e. circumventing renderscript calls). can create output allocation (temp one) , use return output allocation of 'foreach' call, copy surface linked output allocation , not crash, although strange pixelation effects in video.

i'm still bit new renderscript there thread safety issues not aware of? or perhaps bug in rs()?

here how configuring input , output allocations:

 android.renderscript.element elemin = android.renderscript.element.createpixel(mrs, android.renderscript.element.datatype.unsigned_8, android.renderscript.element.datakind.pixel_rgba);         type.builder typein = new type.builder( mrs, elemin );          mallocationin = allocation.createtyped( mrs,             typein.setx( videowidth ).sety( videoheight ).create(),                allocation.mipmapcontrol.mipmap_none,                 allocation.usage_script ); 

and

  mallocationout = allocation.createtyped( mrs, typeout.setx( videowidth ).sety( videoheight ).create(),                allocation.mipmapcontrol.mipmap_none,                 ( allocation.usage_script | allocation.usage_io_output ) );   

here simple rgb kernel:

 uchar4 __attribute__((kernel)) torgb_color( uchar4 in ) {     float4 ndvipixel;     uchar4 out;      ndvipixel.r = ( float )( in[0] / 255.0 );     ndvipixel.g = ( float )( in[1] / 255.0 );     ndvipixel.b = ( float )( in[2] / 255.0 );     ndvipixel.a = 1.0f;      out = rspackcolorto8888(ndvipixel);     ndvipixel = 0;      return out; } 

lastly, call kernel is:

mscript.foreach_torgb_color( mallocationin, mallocationtemp ); 

update

here's how i'm declaring typeout:

  mallocationout = allocation.createtyped( mrs, typeout.setx( videowidth ).sety( videoheight ).create(),                allocation.mipmapcontrol.mipmap_none,                 ( allocation.usage_script | allocation.usage_io_output ) );  

also, waiting surface created onsurfacetextureavailable event so:

  public void onsurfacetextureavailable( surfacetexture surfacetexture, int width, int height ) {       msurface = new surface( surfacetexture ); } 

after create input , output allocations, use latched 'msurface' set output surface of output allocation, this:

        mallocationout.setsurface( msurface ); 

i have msurface declared static if makes difference. i've tried , without static , still crash.

monitor output here:

04-23 12:59:54.752: a/libc(15192): fatal signal 11 (sigsegv), code 1, fault addr 0x0 in tid 15230 (thread-1697) 04-23 12:59:54.853: i/debug(189): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 04-23 12:59:54.853: i/debug(189): build fingerprint: 'nvidia/wx_na_wf/shieldtablet:5.0.1/lrx22c/29979_515.3274:user/release-keys' 04-23 12:59:54.853: i/debug(189): revision: '0' 04-23 12:59:54.853: i/debug(189): abi: 'arm' 04-23 12:59:54.854: i/debug(189): pid: 15192, tid: 15230, name: thread-1697  >>> helios.android <<< 04-23 12:59:54.854: i/debug(189): signal 11 (sigsegv), code 1 (segv_maperr), fault addr 0x0 04-23 12:59:54.876: i/debug(189):     r0 6f81a568  r1 00000001  r2 00000000  r3 00000000 04-23 12:59:54.877: i/debug(189):     r4 630a3200  r5 6f81a568  r6 00000000  r7 00000001 04-23 12:59:54.877: i/debug(189):     r8 12c24000  r9 7c9a0f40  sl 7e86d404  fp 00000008 04-23 12:59:54.877: i/debug(189):     ip 7f8e1a10  sp 7f8e1970  lr 4211475d  pc 420d3f72  cpsr 200f0030 04-23 12:59:54.878: i/debug(189): backtrace: 04-23 12:59:54.878: i/debug(189):     #00 pc 000d3f72  /system/lib/libart.so (void std::__1::__tree_remove<std::__1::__tree_node_base<void*>*>(std::__1::__tree_node_base<void*>*, std::__1::__tree_node_base<void*>*)+205) 04-23 12:59:54.878: i/debug(189):     #01 pc 00114759  /system/lib/libart.so (art::gc::allocator::rosalloc::refillrun(art::thread*, unsigned int)+232) 04-23 12:59:54.878: i/debug(189):     #02 pc 00114973  /system/lib/libart.so (art::gc::allocator::rosalloc::allocfromrun(art::thread*, unsigned int, unsigned int*)+490) 04-23 12:59:54.879: i/debug(189):     #03 pc 0028ba97  /system/lib/libart.so (artallocobjectfromcodeinitializedrosalloc+98) 04-23 12:59:54.879: i/debug(189):     #04 pc 000a23cb  /system/lib/libart.so (art_quick_alloc_object_initialized_rosalloc+10) 04-23 12:59:54.879: i/debug(189):     #05 pc 001d6359  /data/dalvik-cache/arm/system@framework@boot.oat 04-23 12:59:55.360: i/debug(189): tombstone written to: /data/tombstones/tombstone_01 04-23 12:59:55.361: i/bootreceiver(659): copying /data/tombstones/tombstone_01 dropbox (system_tombstone) 

the issue way accessing input allocation. each element in allocation provided 4 components. but, cannot treated array done here. try instead:

uchar4 __attribute__((kernel)) torgb_color( uchar4 in ) {     float4 tmppixel = convert_float4(in);      //  copy unnecessary, done     //  completeness.     float4 ndvipixel.r = tmppixel.x;            ndvipixel.g = tmppixel.y;            ndvipixel.b = tmppixel.z;            ndvipixel.a = 255.0;     uchar4 out = rspackcolorto8888(ndvipixel);     return out; } 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -