Spotlight
Spotlight

Reputation: 1299

Renderscript blur warnings

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

Answers (2)

Tom Piessens
Tom Piessens

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:

  • I only have the texture creation failed error for portrait shaped bitmaps. square bitmaps, or landscape shaped bitmaps do not trigger these errors.
  • I always have the No Context error (portrait and landscape shaped bitmaps)
  • Despite the fact that I get the error for portrait shaped bitmaps, the processing and the result from the renderscript is fine (see also next 2 points).
  • when I was accessing the allocation in the renderscript via the one dimensional method 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.
  • when I was accessing the allocation via the two dimensional method rsGet(Set)ElementAt_uchar4(gIn,x,y), I still got the errors for portrait shaped bitmaps, but the result of the renderscript was fine.
  • With a messed up result, I mean that the result (a blur) was still recognizable, but it was distorded.
  • I'm also sure that I'm not using a recycled bitmap.
  • The script was also a Blur script, but not the intrinsic one. (https://github.com/kikoso/android-stackblur) (not written by myself)... I noticed the above topics by trying to debug when I noticed that portrait shaped bitmaps were not blurred correctly.

Upvotes: 2

shushper
shushper

Reputation: 1089

I had the same error because i used recycled bitmap. Check that your original bitmap is not recycled.

Upvotes: 0

Related Questions