coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.87k stars 669 forks source link

Crossfade doesn't like JPGs #53

Closed saschpe closed 5 years ago

saschpe commented 5 years ago

Describe the bug When loading a local jpg from the file-system, crossfade(true) causes a crash

To Reproduce Happens when using coil with CircleImageView (didn't test plain ImageView).

Expected behavior No crash.

Logs/Screenshots

2019-08-20 13:38:57.430 19165-19165/foo W/System.err: java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:550)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:557)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:69)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:127)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at android.graphics.Canvas.drawBitmap(Canvas.java:1504)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at coil.drawable.CrossfadeDrawable.draw(CrossfadeDrawable.kt:41)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at de.hdodenhof.circleimageview.CircleImageView.getBitmapFromDrawable(CircleImageView.java:318)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at de.hdodenhof.circleimageview.CircleImageView.initializeBitmap(CircleImageView.java:330)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at de.hdodenhof.circleimageview.CircleImageView.setImageDrawable(CircleImageView.java:263)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at coil.target.ImageViewTarget.setDrawable(ImageViewTarget.kt:62)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at coil.target.ImageViewTarget.onSuccess(ImageViewTarget.kt:22)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at coil.memory.PoolableTargetDelegate.success(TargetDelegate.kt:192)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at coil.RealImageLoader$execute$2$deferred$1.invokeSuspend(RealImageLoader.kt:219)
2019-08-20 13:38:57.430 19165-19165/foo W/System.err:     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at android.os.Handler.handleCallback(Handler.java:873)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at android.os.Looper.loop(Looper.java:193)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6898)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
2019-08-20 13:38:57.431 19165-19165/foo W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Library version 0.6.1

colinrtwhite commented 5 years ago

Looks like CircleImageView requires software rendering which is incompatible with hardware bitmaps. Check out the fix here: https://github.com/coil-kt/coil/issues/31