Giter Site home page Giter Site logo

zjupure / glidewebpdecoder Goto Github PK

View Code? Open in Web Editor NEW
732.0 15.0 90.0 9.12 MB

A Glide WebpDecoder Intergration Library for decoding and displaying webp images

License: Apache License 2.0

Shell 0.06% Java 6.97% Makefile 1.43% C++ 3.11% C 88.43%
android glide webp animated-webp

glidewebpdecoder's Introduction

GlideWebpDecoder

license Maven Central PRs Welcome

GlideWebpDecoder is a Glide integration library for decoding and displaying webp images on Android platforms. It is based on libwebp project and takes some implementation from Fresco and GlideWebpSupport as references.

Features

  • play animated webp images on all Android versions
  • show transparent or lossless webp images on Android devices lower than 4.2.1 (BitmapFactory support webp decode on 4.2+ android system so we have no need to handle)

Dependency Integration

Library is available in MavenCentral. If you build with Gradle, just add the following dependencies to your build.gradle file. Different Glide version is corresponding to different GlideWebpDecoder due to the annotation processor compatibility. The version rule of GlideWebpDecoder is "{major_version}.{glide_version}". For example, if you use glide 4.16.0, the corresponding version of GlideWebpDecoder should be 2.6.4.16.0

Library will only follow the latest three version of Glide. If you use a lower version glide, please clone the project and modify it yourself.

Notice

Since Glide 4.10.0 has migrate to AndroidX, so your project must use AndroidX with Glide 4.10.0+.

WebpDecoder with AndroidX support starts from version 1.6.{GLIDE_VERSION} and won't support glide version below 4.10.0 anymore.

Attention

Since JCenter is being taken down on May 1 2021 and then close their service, so the library has migrate artifacts to Maven Central. See issue #76 for more detail.

Changes:

  • library group id has changed from com.zlc.glide to com.github.zjupure
  • add mavenCentral() in your build.gradle to fetch this library
  • only 2.0 version with glide 4.10~4.16 has been migrated and older version not support anymore

If your project use old library version below 2.0, you should upgrade the library to the latest 2.0 version.

def GLIDE_VERSION = "4.16.0"
// webpdecoder
implementation "com.github.zjupure:webpdecoder:2.6.${GLIDE_VERSION}"
// glide 4.10.0+
implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"

Then you are free to use GlideWebpDecoder just like using other Glide integration library.

Usage

Basic usage see Glide API documents

If you want to use BitmapTransformation or library glide-transformations, please use WebpDrawableTransformation to wrap your original BitmapTransformation when loading image with Glide request.

Code Snippet as follow. Run sample project to see other Glide built-in transformation effect.

Transformation<Bitmap> circleCrop = new CircleCrop();
GlideApp.with(mContext)
        .load(url)
        .optionalTransform(circleCrop)
        .optionalTransform(WebpDrawable.class, new WebpDrawableTransformation(circleCrop))
        .into(imageView);

Proguard

The library use native code to decode webp, so you should put the following lines to your proguard.cfg and keep the jni interface.

-keep public class com.bumptech.glide.integration.webp.WebpImage { *; }
-keep public class com.bumptech.glide.integration.webp.WebpFrame { *; }
-keep public class com.bumptech.glide.integration.webp.WebpBitmapFactory { *; }

Acknowledgement

License

The Library is Apache-2.0-licensed, part code is MIT-licensed see Fresco for detail.

glidewebpdecoder's People

Contributors

alvingao avatar dalinaum avatar dstukalov avatar ggikko avatar tougee avatar windsekirun avatar zjupure avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glidewebpdecoder's Issues

oom

Glide.with(holder.getContext()).load(data.getCover_gif())
.optionalTransform(WebpDrawable.class,new WebpDrawableTransformation(new MultiTransformation<>(new CenterCrop(),roundedCorners)))
.into(iv);

在recyclerview里用,100% oom

error when automake

Makefile.am:4: error: WANT_MUX does not appear in AM_CONDITIONAL
Makefile.am:7: error: WANT_DEMUX does not appear in AM_CONDITIONAL
Makefile.am:13: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
Makefile.am:43: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
Makefile.am:11: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:11: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:11: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:11: If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:11: its definition is in aclocal's search path.
Makefile.am:41: error: 'pkgconfig_DATA' is used but 'pkgconfigdir' is undefined
dec/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
dec/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
dec/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
dec/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
dec/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
dec/Makefile.am:2: its definition is in aclocal's search path.
demux/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
demux/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
demux/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
demux/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
demux/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
demux/Makefile.am:2: its definition is in aclocal's search path.
demux/Makefile.am:18: error: 'pkgconfig_DATA' is used but 'pkgconfigdir' is undefined
dsp/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
dsp/Makefile.am:14: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
dsp/Makefile.am:153: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
dsp/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
dsp/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
dsp/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
dsp/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
dsp/Makefile.am:2: its definition is in aclocal's search path.
enc/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
enc/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
enc/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
enc/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
enc/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
enc/Makefile.am:2: its definition is in aclocal's search path.
mux/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
mux/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
mux/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
mux/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
mux/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
mux/Makefile.am:2: its definition is in aclocal's search path.
mux/Makefile.am:22: error: 'pkgconfig_DATA' is used but 'pkgconfigdir' is undefined
utils/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
utils/Makefile.am:4: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
utils/Makefile.am:49: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
utils/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
utils/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
utils/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
utils/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
utils/Makefile.am:2: its definition is in aclocal's search path.

Webp的动图只能使用ARGB_888这种方法加载吗?

WebpDecoder

    /** @Override Added in Glide 4.4.0 */
    public void setDefaultBitmapConfig(Bitmap.Config config) {
        if (config != Bitmap.Config.ARGB_8888) {
            throw new IllegalArgumentException("Unsupported format: " + config
                    + ", must be one of " + Bitmap.Config.ARGB_8888);
        }

        mBitmapConfig = config;
    }

NoSuchMethodError

03-28 21:27:13.863 21015-21015/com.bunz.dev I/Glide: Root cause (1 of 1) java.lang.NoSuchMethodError: No direct method <init>(I)V in class Lcom/bumptech/glide/util/LruCache; or its super classes (declaration of 'com.bumptech.glide.util.LruCache' appears in /data/app/com.sample-2/split_lib_directories_apk.apk) at com.bumptech.glide.integration.webp.decoder.WebpDecoder.<init>(WebpDecoder.java:72) at com.bumptech.glide.integration.webp.decoder.ByteBufferWebpDecoder.decode(ByteBufferWebpDecoder.java:73) at com.bumptech.glide.integration.webp.decoder.ByteBufferWebpDecoder.decode(ByteBufferWebpDecoder.java:30) at com.bumptech.glide.integration.webp.decoder.StreamWebpDecoder.decode(StreamWebpDecoder.java:61) at com.bumptech.glide.integration.webp.decoder.StreamWebpDecoder.decode(StreamWebpDecoder.java:24) at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:72) at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:55) at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:45) at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:58) at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:43) at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:498) at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:469) at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:455) at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:407) at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:376) at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:112) at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onDataReady(MultiModelLoader.java:133) at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:52) at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:97) at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:299) at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269) at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)

Possibly because of using older version of Glide?

动画播放帧率显著降低

播放 animated webp 在三星 Galaxy J3 pro (手机并不差)上帧率明显下降,本来一秒30帧的 webp, we用 chrome 播放很自然,播放起来感觉只有 10 帧

Usage without Transformation

Hi ... I would like to know how I can use this decoder when I don't want to apply any kind of transformation (or use the default one).

Thanks in advance

Some animated WebP images are broken when applying transformations

When applying transformations to some animated WebP images, the result animation looks broken.

For example, with the following code:

Glide.with(this)
        .load("https://mathiasbynens.be/demo/animated-webp-supported.webp")
        .apply(new RequestOptions().optionalTransform(WebpDrawable.class, new WebpDrawableTransformation(new CircleCrop())))
        .into(imageView);
// Dependencies
def GLIDE_VERSION = "4.7.1"
implementation "com.zlc.glide:webpdecoder:0.0.8.${GLIDE_VERSION}"
implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"

The result looks like this:

glide_webp_decoder_demo

Without applying transformations, the images are ok and the animation looks perfect.

同时使用多种Transform

我想要同时使用圆角和CropCenter,没效果,demo只使用了一个,请问现在的版本能否支持使用多个Transform?

Supertypes of the following classes cannot be resolved

Hello, I am getting the following error when trying to implement this library :/ .. Can you please guide me on how to fix it? Thanks in advance.

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: [FitCenter, CenterCrop, CircleCrop]

error when automake

Makefile.am:4: error: WANT_MUX does not appear in AM_CONDITIONAL
Makefile.am:7: error: WANT_DEMUX does not appear in AM_CONDITIONAL
Makefile.am:13: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
Makefile.am:43: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
Makefile.am:11: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:11: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:11: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:11: If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:11: its definition is in aclocal's search path.
Makefile.am:41: error: 'pkgconfig_DATA' is used but 'pkgconfigdir' is undefined
dec/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
dec/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
dec/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
dec/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
dec/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
dec/Makefile.am:2: its definition is in aclocal's search path.
demux/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
demux/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
demux/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
demux/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
demux/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
demux/Makefile.am:2: its definition is in aclocal's search path.
demux/Makefile.am:18: error: 'pkgconfig_DATA' is used but 'pkgconfigdir' is undefined
dsp/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
dsp/Makefile.am:14: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
dsp/Makefile.am:153: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
dsp/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
dsp/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
dsp/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
dsp/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
dsp/Makefile.am:2: its definition is in aclocal's search path.
enc/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
enc/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
enc/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
enc/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
enc/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
enc/Makefile.am:2: its definition is in aclocal's search path.
mux/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
mux/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
mux/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
mux/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
mux/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
mux/Makefile.am:2: its definition is in aclocal's search path.
mux/Makefile.am:22: error: 'pkgconfig_DATA' is used but 'pkgconfigdir' is undefined
utils/Makefile.am:1: error: AM_CPPFLAGS must be set with '=' before using '+='
utils/Makefile.am:4: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
utils/Makefile.am:49: error: BUILD_LIBWEBPDECODER does not appear in AM_CONDITIONAL
utils/Makefile.am:2: error: Libtool library used but 'LIBTOOL' is undefined
utils/Makefile.am:2: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
utils/Makefile.am:2: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
utils/Makefile.am:2: If 'LT_INIT' is in 'configure.ac', make sure
utils/Makefile.am:2: its definition is in aclocal's search path.

Failed to import

I had an error with "bintrayUsername", so I removed what's related to it , but then I got this error:

No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

image

How can I import it well?

Request: update sample and repository webpage

This isn't available anymore when using the instructions on the repository:

Transformation<Bitmap> circleCrop = new CircleCrop();
GlideApp.with(mContext)
        .load(url)
        .optionalTransform(circleCrop)
        .optionalTransform(WebpDrawable.class, new WebpDrawableTransformation(circleCrop))
        .into(imageView);

Instead of "GlideApp", we have just "Glide", and there is no "optionalTransform". Instead we have "apply".

It even says so on the links of the repository:

https://github.com/wasabeef/glide-transformations
https://bumptech.github.io/glide/doc/transformations.html

Attached sample POC that follows the instructions, but if you use the code in the instructions, it will fail to build.

AnimatedWebPTest.zip

CacheControl.NONE cache stategy is not support yet.

WebpFrameCacheStrategy has three strategy contains NONE, AUTO, ALL. but the code limit the min cache size to five.

At 76 line in WebpDecoder:

int maxCacheSize = MAX_FRAME_BITMAP_CACHE_SIZE;
if (mCacheStrategy.cacheAll()) {
maxCacheSize = webPImage.getFrameCount();
} else {
maxCacheSize = Math.max(maxCacheSize, mCacheStrategy.getCacheSize());
}

CenterInside | CenterCrop can't support WEBP

device : Pixel 2 / android 9

implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
implementation "com.zlc.glide:webpdecoder:1.6.4.10.0"

Just use FitCenter / CircleCrop

Transformation fitCenter = new FitCenter();
request.optionalTransform(fitCenter)
.optionalTransform(WebpDrawable.class, new WebpDrawableTransformation(fitCenter));

The onFrameReady method in class WebpFrameLoader may have bug

In line 209, it is necessary to add the judgment of the flag "isRunning". Since the message of the handler is delayed, the delaytarget still holds a reference to the Bitmap. If there is a view that uses the same Bitmap at this time, it will cause drawing problems such as overlapping images.

NullPointerException

使用场景:Tabhost+Fragment+RecyclerView(Grid)
切换界面,通过view.setVisibilityChangeListener监听View的显示状态,通过WebpDrawable来控制动画播放,来回滑动列表几次很容易出现这个崩溃。
日志如下:
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.bumptech.glide.integration.webp.WebpImage.getFrameCount()' on a null object reference
at com.bumptech.glide.integration.webp.decoder.WebpDecoder.getFrameCount(WebpDecoder.java:120)
at com.bumptech.glide.integration.webp.decoder.WebpFrameLoader.getFrameCount(WebpFrameLoader.java:136)
at com.bumptech.glide.integration.webp.decoder.WebpDrawable.startRunning(WebpDrawable.java:154)
at com.bumptech.glide.integration.webp.decoder.WebpDrawable.start(WebpDrawable.java:142)

另外,CPU占用挺高的,不知道能否优化。

Cannot change the visibility of a recycled resource. Ensure that you unset the Drawable from your View before changing the View's visibility.

java.lang.RuntimeException:Unable to destroy activity {xxx.MainActivity}: java.lang.IllegalArgumentException: Cannot change the visibility of a recycled resource. Ensure that you unset the Drawable from your View before changing the View's visibility.

2 android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4521)
3 ......
4 Caused by:
5 java.lang.IllegalArgumentException:Cannot change the visibility of a recycled resource. Ensure that you unset the Drawable from your View before changing the View's visibility.
6 com.bumptech.glide.util.Preconditions.checkArgument(Preconditions.java:19)
7 com.bumptech.glide.integration.webp.decoder.WebpDrawable.setVisible(WebpDrawable.java:182)
8 android.widget.ImageView.onVisibilityAggregated(ImageView.java:1594)
9 android.view.View.dispatchDetachedFromWindow(View.java:18422)
10 android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3771)
11 android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3771)
12 android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3771)
13 android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3771)
14 android.view.ViewGroup.removeViewInternal(ViewGroup.java:5363)
15 android.view.ViewGroup.removeViewInternal(ViewGroup.java:5334)
16 android.view.ViewGroup.removeView(ViewGroup.java:5265)
17 android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1550)
18 android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
19 android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
20 android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
21 android.support.v4.app.FragmentManagerImpl.dispatchDestroyView(FragmentManager.java:3254)
22 android.support.v4.app.Fragment.performDestroyView(Fragment.java:2674)
23 android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1533)
24 android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
25 android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
26 android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
27 android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3260)
28 android.support.v4.app.FragmentController.dispatchDestroy(FragmentController.java:274)
29 android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:419)
30 android.support.v7.app.AppCompatActivity.onDestroy(AppCompatActivity.java:210)

Possible bug: animation can't resume after some time

I wanted to use this library as a way to pass a Bitmap that was drawn to, frame by frame.

For this, I had to have a workaround that draws the Drawable (GifDrawable or WebpDrawable) into a Bitmap , and then decide what to do with it.

It works very well, but if I let the device sleep for a while (about 20 seconds or so), and return to it, it fails to resume the animation. If I turn off the screen and turn it on again after a short time, it works fine, though.

Any idea why?

Attached sample project to show the issue.

AnimatedWebPTest.zip

Also attached video to show issue.

device-2018-11-10-144519.zip

Tested on Pixel 2 with Android P.

giflib

项目里面有另外一个模块,使用的是giflib,这样使用Glide加载GIF图也可以提升效率,所以为什么不使用这个呢?跟webpdecoder这个模块有做什么对比吗?求告知~

Unable to convert com.bumptech.glide.integration.webp.decoder.WebpDrawable@4e4c26c to a Bitmap

在demo上可以加在网络webp动图,但在我们公司项目上加载不了(只能加载常规webp图片),好神奇,报错日志如下。

06-28 16:51:02.142 2591-2827/com.hdwawa.claw E/GlideExecutor: Request threw uncaught throwable
java.lang.IllegalArgumentException: Unable to convert com.bumptech.glide.integration.webp.decoder.WebpDrawable@4e4c26c to a Bitmap
at com.bumptech.glide.load.resource.bitmap.DrawableTransformation.transform(DrawableTransformation.java:56)
at com.bumptech.glide.load.engine.DecodeJob.onResourceDecoded(DecodeJob.java:534)
at com.bumptech.glide.load.engine.DecodeJob$DecodeCallback.onResourceDecoded(DecodeJob.java:598)
at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:46)
at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:58)
at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:43)
at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:501)
at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:472)
at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:458)
at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:410)
at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:379)
at com.bumptech.glide.load.engine.SourceGenerator.onDataFetcherReady(SourceGenerator.java:135)
at com.bumptech.glide.load.engine.DataCacheGenerator.onDataReady(DataCacheGenerator.java:95)
at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:74)
at com.bumptech.glide.load.engine.DataCacheGenerator.startNext(DataCacheGenerator.java:75)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:49)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:272)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)

Why you set attribute allowBackup with value "flase" in library?

Why you set attribute allowBackup with value "flase" in library?

I think allowBackup attribute shuld only be used in App, not in library.

else, if you have another library set the attribute with value "ture", when you clean by gradle, gradle will say error like this.

Error:Execution failed for task ':lib:processDebugAndroidTestManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(true) from [cn.xxx.android.framework:core:12.32] AndroidManifest.xml:69:9-35
  	is also present at [com.zlc.glide:webpdecoder:0.0.3] AndroidManifest.xml:9:18-45 value=(false).
  	Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at manifestMerger1393219201869525967.xml:7:g5-9:19 to override.

So, can you remove the attribute allowBackup? Then update release version, thank you.
It's not a fatal error, but it's boring when you clean.

<application android:allowBackup="false"/>

Just delete above line. Thank you very much.

.centerCrop() can not work

GlideApp.with(this)
.load("http://hbpic-10057247.file.myqcloud.com/emoji/shanmeng/0c31ffcaf7ad7ece0d7c7b1e999f76a9.webp")
.centerCrop()
.into(mImageView);

java.lang.IllegalArgumentException(Unable to convert com.bumptech.glide.integration.webp.decoder.WebpDrawable@9240340 to a Bitmap)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.lang.IllegalArgumentException: Unable to convert com.bumptech.glide.integration.webp.decoder.WebpDrawable@9240340 to a Bitmap

Can you support getLoopCount at WebpDrawable

I need to get loop count from WebpDrawable.
I just want handle setLoopCount when loop count is too large value or infinite.
But WebpDrawable doesn't have getLoopCount().
Is it available?

0.0.4cannot use

0.0.3 is normal,upgrade to 0.0.4,the image do not show and animate.

Stopped Webp drawable in recyclerview get distorted

I have a list of webp images in recycler view.
Each of webp image is displayed fine, the scrolling is very smooth. There is only 1 problem.
When I stop a webp drawable, then scroll the list, the stopped webp drawable get distorted and sometimes it displays other webp drawable in the list.

device-2018-06-09-193529 1

The code that I use to stop/start the webp.

                    Drawable drawable = mIvGif.getDrawable();
                    if (drawable instanceof Animatable) {
                        Animatable animation = (Animatable) drawable;
                        if (animation.isRunning()) {
                            animation.stop();
                        } else {
                            animation.start();
                        }
                    }

Question: does using GifDrawable/WebpDrawable also cache their frames?

I've noticed that compared to another solution I got (here) for showing Gif animation, this one takes a bit more CPU yet also less RAM .

I've tested on this GIF:
example2.zip

I got a similar comparison results with the new ImageDecoder API of Android P.

Does this mean that using this cool Glide library, it doesn't cache the results, and does the decoding over and over, no matter how much free RAM there is?

If so, is there a way to change this behavior? Maybe let it cache up to certain amount of RAM of my choice?

If it does have caching, how can I enhance it?

Or maybe Glide caches the content of the GIF/WEBP, and then the rest is on the CPU ?

There are some exceptions on Android 9.0 when app started

Hello developers:
On Android 9.0 I found some exception information when app started, the stack is as follows:

03-15 16:18:13.307 26854-26854/com.xxx.xxx:dcs W/SoLoader: Cannot get nativeLoad method
    java.lang.NoSuchMethodException: nativeLoad [class java.lang.String, class java.lang.ClassLoader, class java.lang.String]
        at java.lang.Class.getMethod(Class.java:2068)
        at java.lang.Class.getDeclaredMethod(Class.java:2047)
        at com.facebook.soloader.SoLoader.getNativeLoadRuntimeMethod(SoLoader.java:281)
        at com.facebook.soloader.SoLoader.initSoLoader(SoLoader.java:233)
        at com.facebook.soloader.SoLoader.initImpl(SoLoader.java:141)
        at com.facebook.soloader.SoLoader.init(SoLoader.java:120)
        at com.facebook.soloader.SoLoader.init(SoLoader.java:104)
        at com.xxx.xxx.impl.webp.WebpResourceDecoder.<init>(WebpResourceDecoder.java:54)
        at com.xxx.xxx.base.xxx.registerComponents(xxx.java:77)
        at com.bumptech.glide.GeneratedAppGlideModuleImpl.registerComponents(GeneratedAppGlideModuleImpl.java:32)
        at com.bumptech.glide.Glide.initializeGlide(Glide.java:269)
        at com.bumptech.glide.Glide.initializeGlide(Glide.java:219)
        at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:180)
        at com.bumptech.glide.Glide.get(Glide.java:164)
        ...

You may be confused that some classes( For example, WebpResourceDecoder) are not in your project.
In fact, our project integrates your project and GlideWebpSupport (https://github.com/roths/GlideWebpSupport) in a sourcecode-dependent way. We replaced the WebpDecoder and WebpFrameLoader classes in your project with the same-named classes in the GlideWebpSupport project (because we found some problems with the GlideWebpSupport project).

My question is what would be the risk of this error if not handled, because we have not found any abnormality in the loading of dynamic webp.
Due to the lack of familiarity with fresco and c++ mechanisms, I would like to ask if it is necessary to deal with this error, because we only use fresco to load dynamic webp.

Many thanks.

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.