Coder Social home page Coder Social logo

Comments (11)

saket avatar saket commented on July 23, 2024

Very interesting!

I had to mark SubSamplingImageSource as sealed because I wasn't certain about its API stability, especially if it receives multiplatform support. Will offering a SubSamplingImageSource.source(okio.Source) solve your first step?

In the file CoilImageSource.kt the method ImageResult.toSubSamplingImageSource(...) would need to be adjusted to be able to map custom request data to custom SubSamplingImageSource.

Does this not work for your request data because its Result#diskCacheKey is always null?

from telephoto.

lukaspieper avatar lukaspieper commented on July 23, 2024

Thanks for your fast reply and interest in my use case.

Will offering a SubSamplingImageSource.source(okio.Source) solve your first step?

I can provide a decrypting InputStream, so okio.Source should also work thanks to InputStream.source().

Does this not work for your request data because its Result#diskCacheKey is always null?

I debugged this and result.diskCacheKey is null. Furthermore I would prefer not to create an unencrypted copy of the file (even in the app's internal storage).

from telephoto.

saket avatar saket commented on July 23, 2024

Furthermore I would prefer not to create an unencrypted copy of the file (even in the app's internal storage).

I'm curious what's the concern here? App directories are inaccessible to other apps.

I can't think of good ideas to make ZoomableAsyncImage work with custom data types. Do you want to instead roll out your own ZoomableImageSource? You could wrap ZoomableImageSource.coil() or write a new one from scratch.

ZoomableImage(
  image = ZoomableImageSource.encrypted(…),
)

from telephoto.

lukaspieper avatar lukaspieper commented on July 23, 2024

Hi Saket,

I'm curious what's the concern here? App directories are inaccessible to other apps.

I just want to keep the "attack surface" small. Android is very fragmented and at least until Android 12 you could utilize adb backup to dump the app's internal storage without root. On the other hand, there should also be a performance impact when copying files (on cache miss).

Do you want to instead roll out your own ZoomableImageSource?

I started digging into ZoomableImageSource and I think this will likely work for my use case. To test it we need to implement SubSamplingImageSource.source(okio.Source) or SubSamplingImageSource.inputStream(InputStream) first.

I'm quite busy the upcoming week but after that I could create a PR for the first step if you like.

from telephoto.

saket avatar saket commented on July 23, 2024

Sure, please go ahead!

from telephoto.

saket avatar saket commented on July 23, 2024

Alternatively, could you provide a custom disk cache to Coil that is backed by a fake in-memory file system?

from telephoto.

lukaspieper avatar lukaspieper commented on July 23, 2024

Hi,

forked your repo, added the methods to SubSamplingImageSource and tried them with an encrypted file in my app, however getting an exception that the image format is not supported or cannot be decoded.

The only way I got it working is to provide a BitmapRegionDecoder directly, however that does not make sense to me because I also initialize that with an InputStream. It should be the same code, just split in two methods.

Will need to spend some more time looking into this. Due to a lack of time in the next days, it could take another week or two. But I'm on it, after that I will try ZoomableImageSource and your latest idea with the fake cache.

from telephoto.

saket avatar saket commented on July 23, 2024

On a second thought, please disregard that. A fake disk cache won't help because BitmapRegionDecoder will expect the file to exist on the real disk system.

I went ahead and implemented SubSamplingImageSource.rawSource(). Wanna try it out on 0.5.0-SNAPSHOT?

from telephoto.

lukaspieper avatar lukaspieper commented on July 23, 2024

I went ahead and implemented SubSamplingImageSource.rawSource(). Wanna try it out on 0.5.0-SNAPSHOT?

Many thanks! I gave it a try and it's working fine. Will test the approach with ZoomableImageSource in den next days.

from telephoto.

lukaspieper avatar lukaspieper commented on July 23, 2024

So basically copied the ZoomableImageSource.coil() implementation, removed everything I do not need and adjusted the work() and toSubSamplingImageSource() methods and it's working fine. Some methods are duplicated, but these are just a few smaller ones.

From my side, the issue would be resolved with the new method. Thanks again!

Maybe one final question, depending on the answer this would be worth a new issue then. Coil offers SubcomposeAsyncImage where I like to use loading, error and success for overlays. Would you consider such a feature?

from telephoto.

saket avatar saket commented on July 23, 2024

Glad to hear!

Coil offers SubcomposeAsyncImage where I like to use loading, error and success for overlays. Would you consider such a feature?

Yes please, let's move this to a new discussion so that it's searchable by others.

from telephoto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.