Reputation: 1299
I use the renderscript support library by Google to blur a Bitmap. It works, but I see an error on the log:
V/RenderScript_jni(20699): RS native mode
V/RenderScript(20699): 0x2a709a80 Launching thread(s), CPUs 4
W/Adreno-RS(20699): <rsdVendorAllocationDestroyQCOM:199>: rsdVendorAllocationDestroy: No context!
E/RenderScript(20699): Successfully loaded runtime: libRSDriver_adreno.so
W/Adreno-RS(20699): <rsdVendorAllocationSetupTexture:647>: ERROR: Runtime texture creation failed err: -30 image: 0x0 alloc: 0x82340000
W/Adreno-RS(20699): <rsdVendorAllocationSetupTexture:649>: ERROR: Runtime texture creation failed type: 8 kind: 11 eleSize: 4
W/Adreno-RS(20699): <rsdVendorAllocationSetupTexture:647>: ERROR: Runtime texture creation failed err: -30 image: 0x0 alloc: 0x93570000
W/Adreno-RS(20699): <rsdVendorAllocationSetupTexture:649>: ERROR: Runtime texture creation failed type: 8 kind: 11 eleSize: 4
The problem is that after the error a garbage collection is called, freezing the UI thread for a while.
I use this code to blur the Bitmap:
final RenderScript rs = RenderScript.create(context); //context IS NOT null
final Allocation input = Allocation.createFromBitmap(rs, original, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
final Allocation output = Allocation.createTyped(rs, input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
script.setRadius(radius /* e.g. 3.f */);
script.setInput(input);
script.forEach(output);
Bitmap ret = original.copy(original.getConfig(), true);
output.copyTo(ret);
Why the No context!
error? How can I avoid that?
PS: I use a Nexus 5 for the tests
Upvotes: 3
Views: 1423
Reputation: 23
I'm slightly disappointed that my previous answer was deleted since the observations clearly pointed to buggy behaviour and they allowed more people helping pinpointing the bug itself.
However I investigated more thoroughly myself. I have created bitmaps of all sizes with width and height between 350 and 450. With each of these bitmap I created an allocation.
On a Nexus 5, the method Allocation.createFromBitmap
always gives the error below in case that (bitmap width % 8) ==
1,2,3 or 4. In all other cases, the allocation was done without errors.
07-31 18:48:07.902: D/Allocation(20508): Width: 417, height: 399
07-31 18:48:07.922: W/Adreno-RS(20508): <rsdVendorAllocationSetupTexture:647>: ERROR: Runtime texture creation failed err: -30 image: 0x0 alloc: 0x9dd20000
07-31 18:48:07.922: W/Adreno-RS(20508): <rsdVendorAllocationSetupTexture:649>: ERROR: Runtime texture creation failed type: 8 kind: 11 eleSize: 4
I suspect a bug, but I cannot find any source code related to rsdVendorAllocationSetupTexture
to dig deeper.
I don't know if the error has some impact or not... (see my notes below for possible impact... for example when using the allocation in a 1 dimension way)
Bypass of this error is possible by choosing the width of the bitmap so that width % 8 == 5,6,7 or 0.
My previous answer that was deleted:
I have the exact same problem on my Nexus 5 and I noticed some additional points:
rsGet(Set)ElementAt_uchar4(gIn,location)
, with location calculated given the width and height of the bitmap, the result from the renderscript was messed up for portrait shaped bitmaps.rsGet(Set)ElementAt_uchar4(gIn,x,y)
, I still got the errors for portrait shaped bitmaps, but the result of the renderscript was fine.Upvotes: 2
Reputation: 1089
I had the same error because i used recycled bitmap. Check that your original
bitmap is not recycled.
Upvotes: 0