Description
Background
We used external texture to display the images in our flutter app. On the Android platform, we draw the Bitmap
onto the SurfaceTexture
, and on the iOS platform, we convert the UIImage
to CVPixelBufferRef
, and finally use the Texture
Widget to display the image. We do this mainly based on the following considerations:
- We hope that any
Bitmap
orUIImage
can be efficiently displayed to flutter app. For example, we need to customize a photo list page, but the native platform API only provide usBitmap
orUIImage
as photo. - Reuse the native platform image loader. the native image loader, such as Glide on the Android platform and SDWebImage on the iOS platform, have implemented a complete set of caching solutions (memory cache, disk cache) and image decoding solutions. In addition, our CDN cropping optimization is also implemented in the native image loader. We hope that flutter app can directly reuse these capabilities.
- Compared with ui.Image, the memory of external texture is not managed by GC, we can precisely control the timing of memory release
Use case
We are currently refactoring this solution, we want to let the external texture can benefit from the ImageCache
logic.
We hope that ImageCache
can no longer dependent on ui.Image, so that we can customize ImageInfo and ImageProvier to cache external texture images in ImageCache.
Proposal
let ImageCache
can no longer dependent on ui.Image,then users can cache custom ImageInfo
Related code:
Expected
ImageInfo
add a property named sizeBytes
, then ImageCache
use it.
sizeBytes = info.sizeBytes;
Actual
sizeBytes = info.image.height * info.image.width * 4;
Activity
github-actions commentedon Sep 11, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -v
and a minimal reproduction of the issue.