Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when using HARDWARE bitmap #20

Open
diegor2 opened this issue Jun 12, 2020 · 4 comments
Open

Crash when using HARDWARE bitmap #20

diegor2 opened this issue Jun 12, 2020 · 4 comments

Comments

@diegor2
Copy link

diegor2 commented Jun 12, 2020

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        GlobalScope.launch(Dispatchers.IO) {
            val url = "https://upload.wikimedia.org/wikipedia/commons/a/ad/Gretag-Macbeth_ColorChecker.jpg"
            val stream = URL(url).openStream()
            val bitmap = BitmapFactory.decodeStream(stream)
                .copy(Bitmap.Config.HARDWARE, false)

            Dali.create(this@MainActivity)
                .load(bitmap)
                .skipCache()
                .blurRadius(12)
                .into(image);
        }
    }
}
2020-06-12 20:31:48.532 23211-23211/com.example.myapplication E/BlurBuilder: Could not set into imageview
    at.favre.lib.dali.builder.exception.BlurWorkerException: androidx.renderscript.RSInvalidStateException: Bad bitmap type: HARDWARE
        at at.favre.lib.dali.builder.blur.BlurWorker.process(BlurWorker.java:153)
        at at.favre.lib.dali.builder.blur.BlurWorker.call(BlurWorker.java:48)
        at at.favre.lib.dali.builder.blur.BlurWorker.call(BlurWorker.java:27)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:798)
     Caused by: androidx.renderscript.RSInvalidStateException: Bad bitmap type: HARDWARE
        at androidx.renderscript.Allocation.elementFromBitmap(Allocation.java:2654)
        at androidx.renderscript.Allocation.typeFromBitmap(Allocation.java:2659)
        at androidx.renderscript.Allocation.createFromBitmap(Allocation.java:2696)
        at androidx.renderscript.Allocation.createFromBitmap(Allocation.java:2749)
        at at.favre.lib.dali.blur.algorithms.RenderScriptGaussianBlur.blur(RenderScriptGaussianBlur.java:24)
        at at.favre.lib.dali.builder.blur.BlurWorker.process(BlurWorker.java:129)
        at at.favre.lib.dali.builder.blur.BlurWorker.call(BlurWorker.java:48) 
        at at.favre.lib.dali.builder.blur.BlurWorker.call(BlurWorker.java:27) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:798) 
@patrickfav
Copy link
Owner

My only guess is, that renderscript is not compatible with the new HARDWARE flag? Again, I think this is a bug that has to be fixed on Google's side.

@diegor2
Copy link
Author

diegor2 commented Jun 15, 2020

Yes, looks like renderscript doesn't support hardware bitmaps. As a workaround for #19 and #20 I'm copying the bitmap to a new one with ARGB_8888 config.

@patrickfav
Copy link
Owner

Do you have a suggestion how to continue with this issue?

@diegor2
Copy link
Author

diegor2 commented Jul 27, 2020

I think Dali could internally check if the bitmap is hardware type and create a software copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants