Image loading for Android backed by Kotlin Coroutines.

Overview

Coil

An image loading library for Android backed by Kotlin Coroutines. Coil is:

  • Fast: Coil performs a number of optimizations including memory and disk caching, downsampling the image in memory, re-using bitmaps, automatically pausing/cancelling requests, and more.
  • Lightweight: Coil adds ~2000 methods to your APK (for apps that already use OkHttp and Coroutines), which is comparable to Picasso and significantly less than Glide and Fresco.
  • Easy to use: Coil's API leverages Kotlin's language features for simplicity and minimal boilerplate.
  • Modern: Coil is Kotlin-first and uses modern libraries including Coroutines, OkHttp, Okio, and AndroidX Lifecycles.

Coil is an acronym for: Coroutine Image Loader.

Made with ❤️ at Instacart. Translations: 한국어, 中文

Download

Coil is available on mavenCentral().

implementation("io.coil-kt:coil:1.2.0")

Quick Start

To load an image into an ImageView, use the load extension function:

// URL
imageView.load("https://www.example.com/image.jpg")

// Resource
imageView.load(R.drawable.image)

// File
imageView.load(File("/path/to/image.jpg"))

// And more...

Requests can be configured with an optional trailing lambda:

imageView.load("https://www.example.com/image.jpg") {
    crossfade(true)
    placeholder(R.drawable.image)
    transformations(CircleCropTransformation())
}

Image Loaders

imageView.load uses the singleton ImageLoader to enqueue an ImageRequest. The singleton ImageLoader can be accessed using an extension function:

val imageLoader = context.imageLoader

Optionally, you can create your own ImageLoader instance(s) and inject them with dependency injection:

val imageLoader = ImageLoader(context)

If you do not want the singleton ImageLoader, depend on io.coil-kt:coil-base.

Requests

To load an image into a custom target, enqueue an ImageRequest:

val request = ImageRequest.Builder(context)
    .data("https://www.example.com/image.jpg")
    .target { drawable ->
        // Handle the result.
    }
    .build()
val disposable = imageLoader.enqueue(request)

To load an image imperatively, execute an ImageRequest:

val request = ImageRequest.Builder(context)
    .data("https://www.example.com/image.jpg")
    .build()
val drawable = imageLoader.execute(request).drawable

Check out Coil's full documentation here.

Requirements

R8 / Proguard

Coil is fully compatible with R8 out of the box and doesn't require adding any extra rules.

If you use Proguard, you may need to add rules for Coroutines, OkHttp and Okio.

License

Copyright 2021 Coil Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Dropped frames while scrolling in list with multiple spans

    Dropped frames while scrolling in list with multiple spans

    I'm observing some pretty hefty main thread blockage using the latest Coil version (0.11.0) and older ones too. I just migrated from Glide on this app (I've used Coil before in other projects but never in a RV adapter) and everything was smooth until I tried scrolling on the RV. Anyway, tested with both ixel 3 and OnePlus 7T Pro so clearly not an hardware bottleneck.

    My setup is a 5 span GridLayoutManager vertical scrolling. One device has +300 pictures, the other has ~50, so doesn't seem related to the amount of pictures. What I observe is when I start scrolling when Coil is decoding the URIs and starting to display the thumbnails something seems to block the main thread and the whole thing gets blocked and it seems to suspend the entire operation. Sometimes I have to wait 3-4 seconds for it to finish whatever it seems to be doing and it then resumes.

    In the screenrecord I'm attatching you can see a bit of the jank after I open the app fresh. I made each thumb 8px/8px because it's my personal pictures library, but you get the picture. It obviously has worse jank with their actual decoded size (which should be device width / spancount) (5 in this case). The jank is halved if I decrease the span count to 3 or 4. Here's the very simple code I'm using:

    LoadRequest request = LoadRequest.builder(((ViewHolder) holder).b.picture.getContext())
                        .key(item.getUri().toString())
                        .data(item.getUri())
                        .crossfade(false)
                        .target(((ViewHolder) holder).b.picture)
                        .build();
                Coil.execute(request);
    

    Logcat is filled with these GC related operations when doing the scrolling:

    2020-05-19 20:36:44.160 12402-12415/com.franco.graphice I/franco.graphic: Background young concurrent copying GC freed 11330(820KB) AllocSpace objects, 48(1172KB) LOS objects, 0% free, 8438KB/8438KB, paused 124us total 157.193ms
    2020-05-19 20:36:44.455 12402-12415/com.franco.graphice I/franco.graphic: Background concurrent copying GC freed 22434(2113KB) AllocSpace objects, 127(3216KB) LOS objects, 49% free, 7161KB/13MB, paused 438us total 288.432ms
    2020-05-19 20:36:45.609 12402-12415/com.franco.graphice I/franco.graphic: Background young concurrent copying GC freed 28249(2948KB) AllocSpace objects, 190(4884KB) LOS objects, 0% free, 13MB/13MB, paused 590us total 693.969ms
    2020-05-19 20:36:45.772 12402-12437/com.franco.graphice I/franco.graphic: Waiting for a blocking GC ProfileSaver
    2020-05-19 20:36:46.126 12402-12415/com.franco.graphice I/franco.graphic: Background concurrent copying GC freed 46990(4091KB) AllocSpace objects, 222(5452KB) LOS objects, 49% free, 10MB/20MB, paused 1.728ms total 515.818ms
    2020-05-19 20:36:46.126 12402-12437/com.franco.graphice I/franco.graphic: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 354.762ms
    2020-05-19 20:36:48.146 12402-12415/com.franco.graphice I/franco.graphic: Background young concurrent copying GC freed 111714(5587KB) AllocSpace objects, 253(6552KB) LOS objects, 0% free, 22MB/22MB, paused 300us total 851.007ms
    2020-05-19 20:36:48.421 12402-12415/com.franco.graphice I/franco.graphic: Background concurrent copying GC freed 125680(7618KB) AllocSpace objects, 372(9332KB) LOS objects, 49% free, 8377KB/16MB, paused 654us total 258.322ms
    2020-05-19 20:36:50.169 12402-12415/com.franco.graphice I/franco.graphic: Background concurrent copying GC freed 122438(7099KB) AllocSpace objects, 230(5824KB) LOS objects, 49% free, 5686KB/11MB, paused 48us total 438.112ms
    

    Also it's a bit better when using BitmapConfig RGB_565, but just a tiny bit. With the default BitmapConfig I see tons of these logcat messages:

    2020-05-19 20:38:15.978 12923-12923/com.franco.graphice I/Choreographer: Skipped 40 frames!  The application may be doing too much work on its main thread.
    2020-05-19 20:38:16.211 12923-12965/com.franco.graphice I/OpenGLRenderer: Davey! duration=914ms; Flags=0, IntendedVsync=5662959106048, Vsync=5663625772688, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=5663641456128, AnimationStart=5663641473576, PerformTraversalsStart=5663642302847, DrawStart=5663719940563, SyncQueued=5663865801775, SyncStart=5663866294692, IssueDrawCommandsStart=5663867129952, SwapBuffers=5663869075161, FrameCompleted=5663874209172, DequeueBufferDuration=187000, QueueBufferDuration=1022000, 
    2020-05-19 20:38:16.321 12923-12936/com.franco.graphice I/franco.graphic: Background concurrent copying GC freed 108152(11MB) AllocSpace objects, 478(11MB) LOS objects, 50% free, 17MB/34MB, paused 201us total 1.090s
    

    Any clues or question that I can answer to help you narrow it down somehow?

    Thanks I hope this was clear enough.

    bug 
    opened by franciscofranco 42
  • A gif is playing very fast

    A gif is playing very fast

    tumblr_ku2pvuJkJG1qz9qooo1_r1_400

    Plays really fast than how it is shown in Android Gallery and Chrome. Issue occurs while using ImageDecoderDecoder. If only GifDecoder is used, gif doesn't play at all.

    How do I load this gif? Checkout #539

    This is how it looks when I load it:

    record.mp4.zip

    bug help wanted 
    opened by rupinderjeet 21
  • How to debug cancellation of load requests

    How to debug cancellation of load requests

    I am migrating from Picasso to Coil. It went quite easy as the APIs are very similar.

    I have a custom Fetcher for loading internal schemes.

    I load a list of items in a recycler view, each having a logo loaded with Coil by the custom fetcher.

    When I scroll up and down the recycler view list, I see that sometimes a wrong logo is displayed on some of the items. It seems as if the load request, which wasn't done, jumped to one of the new items coming into view. I have to scroll up and down the list a few times to trigger it.

    My guess it that the inflight request connected to the image view isn't cancelled or maybe a bitmap is reused?

    I am pretty sure it isn't a problem with the recycler view recycling of views as Picasso handled it just fine. Also the test on the items is correct. Only the logo is wrong.

    Can you guide me on how to debug this?

    question 
    opened by clhols 20
  • [coil-video] Fails to load preview for video

    [coil-video] Fails to load preview for video

    Describe the bug When I'm trying to load preview for video that I picked from my device I'm getting an exception:

    2020-05-22 23:40:14.907 27387-27387/com.example.android I/System.out: load uri: content://com.android.providers.media.documents/document/video%3A158545
    2020-05-22 23:40:14.956 27387-27462/com.example.android D/skia: --- Failed to create image decoder with message 'unimplemented'
    2020-05-22 23:40:14.956 27387-27462/com.example.android D/skia: --- Failed to create image decoder with message 'unimplemented'
    2020-05-22 23:40:14.965 27387-27387/com.example.android I/RealImageLoader: 🚨 Failed - content://com.android.providers.media.documents/document/video%3A158545 - java.lang.IllegalStateException: BitmapFactory returned a null Bitmap. Often this means BitmapFactory could not decode the image data read from the input source (e.g. network or disk) as it's not encoded as a valid image format.
    2020-05-22 23:40:14.967 27387-27387/com.example.android E/RealImageLoader: java.lang.IllegalStateException: BitmapFactory returned a null Bitmap. Often this means BitmapFactory could not decode the image data read from the input source (e.g. network or disk) as it's not encoded as a valid image format.
            at coil.decode.BitmapFactoryDecoder.decode(BitmapFactoryDecoder.kt:177)
            at coil.RealImageLoader$loadData$2.invokeSuspend(RealImageLoader.kt:349)
            at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
            at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
            at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
            at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
            at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
            at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
    2020-05-22 23:40:17.922 27387-27523/com.example.android V/FA: Inactivity, disconnecting from the service
    

    Expected behavior Would like to see thumbnail

    To Reproduce The code is pretty standard

    
    val imageLoader = ImageLoader.Builder(requireContext())
                .componentRegistry {
                    add(VideoFrameFileFetcher(requireContext()))
                    add(VideoFrameUriFetcher(requireContext()))
                }
                .build()
    
    val request = LoadRequestBuilder(requireContext())
                    .data(uri)
                    .videoFrameMillis(2000)
                    .target(myImageView)
                    .build()
                imageLoader.execute(request)
    

    Version coil-version 0.11.0 Android 9 coil-video is added

    bug 
    opened by gabin8 19
  • Software rendering doesn't support hardware bitmaps

    Software rendering doesn't support hardware bitmaps

    java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:550) at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:557) at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:69) at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:127) at android.graphics.Canvas.drawBitmap(Canvas.java:1516) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545) at android.widget.ImageView.onDraw(ImageView.java:1360) at android.view.View.draw(View.java:20332) at android.view.View.draw(View.java:20194) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1767) at android.view.View.draw(View.java:20340) at android.view.View.draw(View.java:20194) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5030) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at android.view.View.draw(View.java:20340) at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4429) at android.view.View.draw(View.java:20194) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1767) at android.view.View.draw(View.java:20340) at android.view.View.draw(View.java:20194) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at android.view.View.draw(View.java:20192) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1767) at android.view.View.draw(View.java:20340) at android.view.View.draw(View.java:20194) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at android.view.View.draw(View.java:20192) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at android.view.View.draw(View.java:20192) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at android.view.View.draw(View.java:20192) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at android.view.View.draw(View.java:20192) at android.view.ViewGroup.drawChild(ViewGroup.java:4395) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174) at android.view.View.draw(View.java:20340) at com.android.internal.policy.DecorView.draw(DecorView.java:781) at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:3582) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3472) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3244) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2598) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1521) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7437) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:965) at android.view.Choreographer.doCallbacks(Choreographer.java:777) at android.view.Choreographer.doFrame(Choreographer.java:709) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193)

    bug 
    opened by mt131 19
  • Enable native support for SVG format without boilerplate

    Enable native support for SVG format without boilerplate

    Currently using Glide to load SVG images and the implementation is quite clunky in order to do so. See: https://stackoverflow.com/questions/35507893/does-glide-have-a-method-for-loading-both-png-and-svg

    As a fresh new library hot off the presses, I'd like to see Coil gracefully (and optimally) handle these file formats without a ton of boilerplate.

    EDIT: WebP is already supported, so this enhancement request is more about formats that require an external library for decoding (and a Decoder).

    Thanks!

    enhancement 
    opened by 0xMatthewGroves 19
  • Priority handling for identical data request

    Priority handling for identical data request

    Is your feature request related to a problem? Please describe. At some point in my application an image can be loaded multiple times at different size, but I have no control over the order of the requests. Since I'm allowing inexact size it would be nice if there could be some way to optimize the request for the same data to be better ordered so that cache works better.

    I'm often ending up with all request running more or less simultaneously or in smaller to higher order leading to no usage of the memory cache as each request are larger than the previous one.

    Since I don't know in advance if the images will be displayed multiple times I don't want to use a tons of memory and always use Size(Original).

    I've not found a way to do anything with interceptors or the current pipeline but I maybe missed something.

    enhancement 
    opened by Tolriq 18
  • Check if view is attached to window before checking hwAcceleration

    Check if view is attached to window before checking hwAcceleration

    I've been able to reproduce the issue sometimes which led me to believe this is some kind of a race condition in checking the hw acceleration capabilities for which we need the View to be attached to the window. To be safe, I now check if we're attached to window before checking for the HW acceleration.

    Please test and let me know if this works for you.

    Signed-off-by: Mario Danic [email protected]

    opened by mario 16
  • Image flickers when url changes for rememberImagePainter

    Image flickers when url changes for rememberImagePainter

    Currently I'm using a library to reorder items in a LazyColumn. The library works and functions as expected. The issue I'm running into is that when an item is reordered in the list, it causes a recomposition because my state has changed since the position of the item has changed. This is fine, but when items in my list recompose, they might have different urls so it tries to load the new image for both items that had their positions change. This causes a flicker as it tries to load new images. I've tried to use caching to prevent rememberImagePainter from having to go fetch the image again but I don't think that's how that works. I've tried to prevent the request from going through by providing an ExecuteCallback that returned false if the state wasn't empty and that didn't work either.

    I would expect to be able to configure coil to not re-load an image when a url changes but instead use a cached version if it exists.

    I'm using version 1.3.2 and it's not device specific.

    opened by cj1098 15
  • Images cropped while load for the first time in recycler view if I kept scrolling

    Images cropped while load for the first time in recycler view if I kept scrolling

    Describe the bug I have some images cropped when loading them for the first time and kept scrolling while loading

    Expected behavior All Images should be fully loaded

    To Reproduce Load about 10 images in recycler view and start scrolling

    Logs/Screenshots Screen record: https://drive.google.com/file/d/1zBgkdsWDcEoFWy8FU66Uud0VTgF9j_pJ/view?usp=sharing

    Version I am on version 1.1.1 , It was tested on android 10

    bug needs info 
    opened by Omar-Alnajjar 15
  • Get the image file from a preloaded image

    Get the image file from a preloaded image

    Is your feature request related to a problem? Please describe. I'm looking for a way to get the image file from a preloaded image, but seems Coil lacks this feature at the moment.

    Describe the solution you'd like On Glide I do:

    val preloadedImageFile = Glide
        .with(context)
        .downloadOnly()
        .load(imageUrl)
        .submit()
        .get()
    

    Would be nice if we have at least one of these options in Coil:

    Coil.getFile(imageUrl)
    
    Coil.load(context, imageUrl) {
        target(object : FileTarget {
            override fun onSuccess(result: File) {
                
            }
        })
    }
    
    enhancement 
    opened by adrielcafe 15
  • only callback onCancel ;no callback onSuccess

    only callback onCancel ;no callback onSuccess

    Describe the bug Call image loading multiple times in a short period of time. There will be only cancel callback

    To Reproduce image

    Logs/Screenshots image

    image

    Version 1.1.1-1.4.0

    opened by geekwwzhang 1
  • Update okio to v3.3.0

    Update okio to v3.3.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | com.squareup.okio:okio-fakefilesystem | 3.2.0 -> 3.3.0 | age | adoption | passing | confidence | | com.squareup.okio:okio | 3.2.0 -> 3.3.0 | age | adoption | passing | confidence |


    Release Notes

    square/okio

    v3.3.0

    2023-01-07

    • Fix: Don't leak resources when use {} is used with a non-local return. We introduced this performance and stability bug by not considering that non-local returns execute neither the return nor catch control flows.
    • Fix: Use a sealed interface for BufferedSink and BufferedSource. These were never intended for end-users to implement, and we're happy that Kotlin now allows us to express that in our API.
    • New: Change internal locks from synchronized to ReentrantLock and Condition. We expect this to improve help when using Okio with Java virtual threads ([Project Loom][loom]).
    • Upgrade: [Kotlin 1.8.0][kotlin_1_8_0].

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • DiskCache is never used

    DiskCache is never used

    Describe the bug A clear and concise description of what the bug is. Please enable logging and attach any stack traces. Bug reports without reproduction steps are likely to be closed.

    To Reproduce How can we reproduce this? Please attach a small project that reproduces the bug.

    Logs/Screenshots If applicable, add logs or screenshots to help explain your problem.

    Version What library version are you using? Does this occur on a specific API level or Android device? version: 2.2.2

    When the image is not in the memoryCache, you should go to diskCache to find it, but Coil is not, but directly to initiate a network request, request back the image, save to DiskCache, and save to MemoryCache. Then go to memoryCache to load, diskCache is not used at all.

    The correct logic should be to look for it from memoryCache first, if you can't find it, go to DiskCache to find it, if you can't find it, initiate a network request and go to the server to find it.

    opened by zkoalas 0
  • Apply content scaling to placeholder/error Painter as well

    Apply content scaling to placeholder/error Painter as well

    Is your feature request related to a problem? Please describe.

    I load an image. I know the dimensions beforehand, so I can reserve the space with a simple Painter which paints a solid color so that the layout will not jump. The painter has an intrinsic size equal to the image.

        AsyncImage(
            model = ImageRequest.Builder(context).data("https://raw.githubusercontent.com/coil-kt/coil/main/logo.svg").crossfade(true).build(),
            placeholder = PlaceholderPainter(
                MaterialTheme.colorScheme.surfaceVariant,
                width = 403, height = 202,
            ),
            contentDescription = contentDescription,
            contentScale = ContentScale.FillWidth
            modifier = modifier,
            alignment = Alignment.Center, 
        )
    

    However, Coil draws the placeholder exactly at the intrinsic size, and does not scale it according to the parameter. The layout still jumps.

    Describe the solution you'd like

    I would like Coil to respect the contentScale setting for the passed placeholder, so that it takes the exact same size as the loaded image.

    I know I can scale the intrinsic size of the Painter according to the container dimensions, but I think it would be nice if Coil resized it automatically.

    Coil version 2.2.2

    enhancement 
    opened by digitalheir 0
  • Didn't load image from disk cache if it loaded with empty string header

    Didn't load image from disk cache if it loaded with empty string header

    Describe the bug If server returns image with empty string in header, then image can't load from disc next session

    To Reproduce If server returns image with empty string in header, then image can't load from disc next session.

    Logs/Screenshots java.lang.IllegalArgumentException: name is empty at okhttp3.Headers$Companion.checkName(Headers.kt:438) at okhttp3.Headers$Companion.access$checkName(Headers.kt:362) at okhttp3.Headers$Builder.addUnsafeNonAscii(Headers.kt:270) at coil.util.-Utils.addUnsafeNonAscii(Utils.kt:239) at coil.network.CacheResponse.(CacheResponse.kt:29) at coil.fetch.HttpUriFetcher.toCacheResponse(HttpUriFetcher.kt:255)

    Version Coil 2.2.2

    To Fix if coil.util.Utils rewrite

    internal fun Headers.Builder.addUnsafeNonAscii(line: String) = apply { val index = line.indexOf(':') require(index != -1) { "Unexpected header: $line" } val name = line.substring(0, index).trim() val content = line.substring(index + 1) require(name.isNotEmpty()) { "Header name can't be empty" } addUnsafeNonAscii(name, content) }

    opened by mmarashan 0
  • Compose: Software rendering doesn't support hardware bitmaps

    Compose: Software rendering doesn't support hardware bitmaps

    Raising, because I haven't seen this with Coil and Compose before.

    This is with Coil 2.2.2 (it's from a prod report, so possibly was older version)

    Fatal Exception: java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
           at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:668)
           at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:675)
           at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:77)
           at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:135)
           at android.graphics.Canvas.drawBitmap(Canvas.java:1648)
           at androidx.compose.ui.graphics.AndroidCanvas.drawImageRect-HPBpro0(AndroidCanvas.java:2)
           at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.drawImage-AZ2fEMs(CanvasDrawScope.java:2)
           at androidx.compose.ui.node.LayoutNodeDrawScope.drawImage-AZ2fEMs(LayoutNodeDrawScope.java:34)
           at androidx.compose.ui.graphics.drawscope.DrawScope.drawImage-AZ2fEMs$default(DrawScope.java:4)
           at androidx.compose.ui.graphics.painter.BitmapPainter.onDraw(BitmapPainter.java:56)
           at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.java:14)
           at coil.compose.AsyncImagePainter.onDraw(AsyncImagePainter.java:7)
           at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.java:14)
           at androidx.compose.ui.draw.PainterModifier.draw(PainterModifier.java:6)
           at androidx.compose.ui.node.DrawEntity.draw(DrawEntity.java:25)
           at androidx.compose.ui.node.LayoutNodeWrapper.drawContainedDrawModifiers(LayoutNodeWrapper.java:3)
           at androidx.compose.ui.node.ModifiedLayoutNode.performDraw(ModifiedLayoutNode.java:2)
           at androidx.compose.ui.node.LayoutNodeWrapper.drawContainedDrawModifiers(LayoutNodeWrapper.java:4)
           at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.java:4)
    

    Other reports like https://github.com/coil-kt/coil/issues/31 seem to be View based.

    My expectation is that by default Coil, will choose the right hardware more. Disabling presumably fixes this, but as it's working in almost all cases, that seems sub-optimal.

    Should this be possible with Coil and Compose?

    opened by yschimke 0
Releases(2.2.2)
Owner
Coil
Image loading for Android backed by Kotlin Coroutines.
Coil
Server Sent Events (SSE) client multiplatform library made with Kotlin and backed by coroutines

OkSSE OkSSE is an client for Server Sent events protocol written in Kotlin Multiplatform. The implementation is written according to W3C Recommendatio

BioWink GmbH 39 Nov 4, 2022
Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in Kotlin with Jetpack Compose and a backed in Kotlin hosted on AppEngine.

Conferences4Hall Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in K

Gérard Paligot 98 Dec 15, 2022
Recycler-coroutines - RecyclerView Auto Add Data Using Coroutines

Sample RecyclerView Auto Add With Coroutine Colaborator Very open to anyone, I'l

Faisal Amir 8 Dec 1, 2022
Blinking-image-view - A variant of Android View that blinks only the source image (not the background)

Blinker View for Android What is this? Blinker View is an Android View that blinks a given drawable. Yes, it's that simple. Place it in your layout an

Milos Marinkovic 4 Jul 29, 2020
Lightweight data loading and caching library for android

ColdStorage A lightweight data loading and caching library for android Quicklinks Feature requests: Got a new requirement? Request it here and it will

Cryptic Minds 41 Oct 17, 2022
Android To-Do MVVM Architecture App written in Kotlin.(ViewModel, ROOM, Livedata, Coroutines)

MVVM-To-Do-App A To-Do application written in kotlin using Android Architectural components What's new? Room + Coroutines - Upgraded Room to v2.1. Roo

Naveen T P 77 Dec 8, 2022
A Kotlin Android library for content provider queries with reactive streams and coroutines.

Pickpocket An Android library for content provider queries with reactive streams and coroutines. Calendar Contacts SMS MMS Files/Media Call Log Bookma

Chris Basinger 27 Nov 14, 2022
Android Library for requesting Permissions with Kotlin Coroutines or AndroidX LiveData

PEKO PErmissions with KOtlin Android Permissions with Kotlin Coroutines or LiveData No more callbacks, builders, listeners or verbose code for request

Marko Devcic 133 Dec 14, 2022
async/await for Android built upon coroutines introduced in Kotlin 1.1

Async/Await A Kotlin library for Android to write asynchronous code in a simpler and more reliable way using async/await approach, like: async { pr

MetaLab 411 Dec 22, 2022
Android News Reader app. Kotlin Coroutines, Retrofit and Realm

News Reader Android News Reader app Code that follows Packt Publishing Kotlin in Practice Video Course Example of Kotlin Coroutine usage, with Realm a

Marko Devcic 22 Oct 3, 2022
Extension functions over Android's callback-based APIs which allows writing them in a sequential way within coroutines or observe multiple callbacks through kotlin flow.

callback-ktx A lightweight Android library that wraps Android's callback-based APIs into suspending extension functions which allow writing them in a

Sagar Viradiya 171 Oct 31, 2022
A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

Nek.12 4 Oct 31, 2022
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture

GithubSearchKMM Github Repos Search - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Depend

Petrus Nguyễn Thái Học 50 Jan 7, 2023
Library to use Kotlin Coroutines from Swift code in KMP apps

KMP-NativeCoroutines A library to use Kotlin Coroutines from Swift code in KMP apps. Flows Kotlin Create an extension property to expose the Flow as a

Rick Clephas 508 Jan 3, 2023
A framework for writing composable parsers based on Kotlin Coroutines.

Parsus A framework for writing composable parsers based on Kotlin Coroutines. val booleanGrammar = object : Grammar<BooleanExpression>() { val ws

Aleksei Semin 28 Nov 1, 2022
RSocket, WebFlux, Reactor, Kotlin, Coroutines

RSocket messaging services communication RSocket, WebFlux, Reactor, Kotlin, Coroutines edge-service <-~-> web-service <-~-> coroutines-service <-~-> r

Maksim Kostromin 2 Nov 12, 2021
A Kotlin coroutines wrapper for IndexedDB.

Kotlin IndexedDB A wrapper around IndexedDB which allows for access from Kotlin/JS code using suspend blocks and linear, non-callback based control fl

JUUL Labs 10 Dec 11, 2022
Small lib for recovering stack trace in exceptions thrown in Kotlin coroutines

Stacktrace-decoroutinator Library for recovering stack trace in exceptions thrown in Kotlin coroutines. Supports JVM(not Android) versions 1.8 or high

null 104 Dec 24, 2022
Learning Playground - Kotlin Coroutines

Coroutines Kotlin Playground Coroutines Learning Playground Colaborator Very ope

Faisal Amir 2 Mar 12, 2022