Skip to content

Extend ImageCache to handle Custom ImageInfo #86402

Closed
@ColdPaleLight

Description

@ColdPaleLight

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:

  1. We hope that any Bitmap or UIImage can be efficiently displayed to flutter app. For example, we need to customize a photo list page, but the native platform API only provide us Bitmap or UIImage as photo.
  2. 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.
  3. 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:

sizeBytes = info.image.height * info.image.width * 4;

Expected

ImageInfo add a property named sizeBytes, then ImageCache use it.

 sizeBytes = info.sizeBytes; 

Actual

 sizeBytes = info.image.height * info.image.width * 4; 

Activity

added
in triagePresently being triaged by the triage team
a: imagesLoading, displaying, rendering images
frameworkflutter/packages/flutter repository. See also f: labels.
c: proposalA detailed proposal for a change to Flutter
c: new featureNothing broken; request for a new capability
and removed
in triagePresently being triaged by the triage team
on Jul 14, 2021
github-actions

github-actions commented on Sep 11, 2021

@github-actions

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.

locked as resolved and limited conversation to collaborators on Sep 11, 2021
added
r: fixedIssue is closed as already fixed in a newer version
on Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: imagesLoading, displaying, rendering imagesc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttercustomer: alibabaframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @ColdPaleLight@darshankawar

      Issue actions

        Extend ImageCache to handle Custom ImageInfo · Issue #86402 · flutter/flutter