Hauke Radtki Hauke Radtki - 4 years ago 186
Android Question

ScriptIntrinsicBlur broken on API 24 on Galaxy S7?

I just recently got the update for the Galaxy S7 to Android 7.0.0 and discovered something strange.

The previous working ScriptIntrinsicBlur now produced partially transparent results. Both on the SupportLibrary version as well as the native one.

I tracked it down to be dependent on the blur radius, where, in general, the larger the radius the less transparent the result is.

So I ran a sweep test over the radius from 0 to 25 (allowed range) pixels over an completely opaque picture.

Android Emulator x86 API 24:

blurRad: 0.025 alpha: 254
...
blurRad: 25.0 alpha: 254


So this creates some transparency for all radii, but is not noticeable.

Galaxy S7, API 24, Build: NRD90M.G930FXXU1DQAO:

blurRad: 0.025 alpha: 10
...
blurRad: 0.25 alpha: 110
...
blurRad: 1.0 alpha: 241


Galaxy S7 alpha over blur radius

For completeness I ran the test on an arm64 emulator with API 24, it generates completely opaque results for all radii.

The results are independent on the size of the bitmap to blur, and of its content (as long as the source alpha is 255 of course)

Additionally I noticed that the ScriptIntrinsicBlur is ~8-10 times slower than before. Even on an HTC one I can blur a 400x400px image with 800fps whereas the Galaxy S7 (API 24) only achieves 90-100fps.

So the question: Can someone reproduce this and is there a workaround?

Answer Source

Seems to me that something is wrong with the GPU RenderScript driver on S7.

Can you try the following command:

adb shell setprop debug.rs.default-CPU-driver 1

And then kill you app and restart it. If the behavior becomes normal, we are sure that something is wrong with the GPU driver, at least for certain input images.

If that is true, there are workaround to bypass the GPU driver, only do so after your code found an API24 S7:

  1. When using native RenderScript, create the context with CREATE_FLAG_LOW_LATENCY flag. RenderScript.create(ctx, RenderScript.ContextType.NORMAL, CREATE_FLAG_LOW_LATENCY)
  2. If using support library, call RenderScript.forceCompat(); before calling RenderScript.create(ctx)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download