Kureev / react-native-blur

React Native Blur component
MIT License
3.78k stars 558 forks source link

Android error: Software rendering doesn't support hardware bitmaps caused by PreDrawBlurController. #624

Open Anas-7 opened 3 months ago

Anas-7 commented 3 months ago

We are facing this error when we try to integrate a library that uses Coil in our app, and had first written the issue below here. I tried using the fixes mentioned here but they don't work and neither does the latest version, i.e., 4.4.0

Describe the bug App shuts down when trying to navigate to hamburger menu made with @react-navigation/drawer that contains a Blurview. Currently, we show a feed where images are displayed with TurboImage. The images load and cache correctly, but on clicking the menu the app closes.

We tried a different library, but faced a similar error. Our crashlytics log point to an error related to Coil and Blurview is attached below.

Expected behavior The issue is due to coil.drawable.CrossfadeDrawable.draw and might have something to do with this

Logs

The two relevant lines according to me are:

eightbitlab.com.blurview.PreDrawBlurController.updateBlur (PreDrawBlurController.java:119) eightbitlab.com.blurview.PreDrawBlurController$1.onPreDraw (PreDrawBlurController.java:50)

The complete log is:

Fatal Exception: java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:726) at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:81) at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:139) at android.graphics.Canvas.drawBitmap(Canvas.java:1665) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:549) at coil.drawable.CrossfadeDrawable.draw(CrossfadeDrawable.kt:79) at android.widget.ImageView.onDraw(ImageView.java:1446) at android.view.View.draw(View.java:24627) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24630) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24630) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24630) at android.widget.ScrollView.draw(ScrollView.java:2019) at com.facebook.react.views.scroll.ReactScrollView.draw(ReactScrollView.java:587) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24630) at android.widget.ScrollView.draw(ScrollView.java:2019) at com.facebook.react.views.scroll.ReactScrollView.draw(ReactScrollView.java:587) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24630) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24630) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24630) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24630) at android.view.View.draw(View.java:24499) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at com.facebook.react.views.view.ReactViewGroup.drawChild(ReactViewGroup.java:836) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:809) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at com.facebook.react.ReactRootView.dispatchDraw(ReactRootView.java:296) at android.view.View.draw(View.java:24497) at android.view.ViewGroup.drawChild(ViewGroup.java:4576) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4337) at android.view.View.draw(View.java:24630) at eightbitlab.com.blurview.PreDrawBlurController.updateBlur(PreDrawBlurController.java:119) at eightbitlab.com.blurview.PreDrawBlurController$1.onPreDraw(PreDrawBlurController.java:50) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1176) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4029) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2718) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9937) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1406) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415) at android.view.Choreographer.doCallbacks(Choreographer.java:1015) at android.view.Choreographer.doFrame(Choreographer.java:945) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1389) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8592) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

Smartphone (please complete the following information):

Additional context This seems to be triggered due to hardware acceleration. I tried testing it with android:hardwareAcceleration="false" and while the code didn't crash, the performance suffered way more than acceptable for us. I'll try and post a reproducible example in a day or two.

MadeinFrance commented 1 month ago

Exact same issue on 4.4.1 simulator + real device.