Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support progressive animated webp #2353

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

chenleejr
Copy link

Motivation

To support progressive animated webp, so that Fresco can play animation while download the image.

  • change WebPDemux to WebPDemuxPartial in webp.cpp
  • modify the DecodeProducer to decode intermediate webp data
  • Although multiple ClosableImage will be generated during the download, I still only use one AnimatedDrawable2. So I modified AnimatedDrawable2 to support playing from the last frame played by the previous data, and added createDrawable(Drawable previousDrawable, CloseableImage image) to DrawableFactory to update Drawable instead of creating a new Drawable
  • add a ControllerListener to AbstractDraweeController to start animation every time data arrives

Test Plan

We can use ImageRequestBuilder.setProgressiveRenderingEnabled to enable the progressive animated webp. I add a switch to ImageFormatWebpFragment in SHOWCASE module so that we can test the function.

    switchProgressive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(sampleUris().createWebpAnimatedUri())
          .setProgressiveRenderingEnabled(isChecked).build();
        draweeWebpAnimated.setController(
          Fresco.newDraweeControllerBuilder()
            .setAutoPlayAnimations(true)
            .setOldController(draweeWebpAnimated.getController())
            .setImageRequest(request)
            .build());
      }
    });

First, we construct a weak network environment, by modifying the proxy configuration or modifying the code of NetworkFetchProducer, and then turning on the switch, we can see that some frames can be played before the image is completely downloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants