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

StateVerifier throw if needed 4.4.0 #2689

Closed
lam-amsiq opened this issue Dec 6, 2017 · 15 comments
Closed

StateVerifier throw if needed 4.4.0 #2689

lam-amsiq opened this issue Dec 6, 2017 · 15 comments

Comments

@lam-amsiq
Copy link

Stack:

Fatal Exception: java.lang.IllegalStateException: Already released
       at com.bumptech.glide.util.pool.StateVerifier$DefaultStateVerifier.throwIfRecycled(StateVerifier.java:44)
       at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:518)
       at com.bumptech.glide.load.engine.EngineJob.handleResultOnMainThread(EngineJob.java:217)
       at com.bumptech.glide.load.engine.EngineJob$MainThreadCallback.handleMessage(EngineJob.java:322)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5584)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
       at dalvik.system.NativeStart.main(NativeStart.java)

Fabric

@sjudd
Copy link
Collaborator

sjudd commented Dec 6, 2017

Let me know if you find a way to reproduce this, or attach a test with a failing test case: http://bumptech.github.io/glide/tut/failing-test-cases.html

@lam-amsiq
Copy link
Author

lam-amsiq commented Dec 11, 2017

We managed to reproduce the error with that additional information:

12-11 13:18:36.540 9220-9220/? W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!
12-11 13:18:36.540 9220-9220/? W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!
12-11 13:18:36.540 9220-9220/? W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!
12-11 13:18:36.719 1429-8786/? W/MdnsClient: Socket thread is null
12-11 13:18:36.823 9220-9220/? W/Glide: Load failed for https://www.app.com/content/portraits-thumb/072/0723544.jpg with size [216x216]
                                        class com.bumptech.glide.load.engine.GlideException: Failed to load resource
                                          Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
                                            Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
                                              Cause (1 of 1): class java.net.UnknownHostException: Unable to resolve host "www.app.com": No address associated with hostname
12-11 13:18:36.823 9220-9220/? I/Glide: Root cause (1 of 1)
12-11 13:18:37.236 9220-9220/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.app, PID: 9220
                                                 java.lang.IllegalStateException: Already released
                                                     at com.bumptech.glide.g.a.b$a.b(StateVerifier.java:44)
                                                     at com.bumptech.glide.request.SingleRequest.a(SingleRequest.java:518)
                                                     at com.bumptech.glide.load.engine.j.c(EngineJob.java:217)
                                                     at com.bumptech.glide.load.engine.j$b.handleMessage(EngineJob.java:322)
                                                     at android.os.Handler.dispatchMessage(Handler.java:98)
                                                     at android.os.Looper.loop(Looper.java:154)
                                                     at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

The problem appears when going offline while glide is loading a remote resource

@sjudd
Copy link
Collaborator

sjudd commented Dec 11, 2017

Can you provide the set of steps that you used to reproduce the error? What load line are you using? How often does it reproduce?

@lam-amsiq
Copy link
Author

lam-amsiq commented Dec 11, 2017

Happened 255 times - Fabric

It happens various place in the code
A load example where we know it can crash:

Glide.with(getContext())
                    .load(account.getProfilePictureThumbUrl())
                    .apply(new RequestOptions()
                            .fitCenter()
                            .centerCrop())
                    .apply(RequestOptions.bitmapTransform(new RoundedCorners(getContext().getResources().getDimensionPixelSize(R.dimen.corner_radius))))
                    .error(getOfflineRequest(R.drawable.as_shared_default_picture_offline, RequestOptions.bitmapTransform(new RoundedCorners(getContext().getResources().getDimensionPixelSize(R.dimen.corner_radius)))))
                    .listener(new RequestListener<Drawable>() {
                        @Override
                        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                            if (picture == null || progress == null) return false;
                            picture.setVisibility(View.VISIBLE);
                            progress.setVisibility(View.INVISIBLE);
                            if (runnableSuccess != null) { runnableSuccess.run(); }
                            return false;
                        }

                        @Override
                        public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                            if (picture == null || progress == null) return false;
                            picture.setVisibility(View.VISIBLE);
                            progress.setVisibility(View.INVISIBLE);
                            if (runnableSuccess != null) { runnableSuccess.run(); }
                            return false;
                        }
                    })
                    .into(picture);

To reproduce:
Start many remote loads with Glide and go offline before Glide is done loading

@sjudd
Copy link
Collaborator

sjudd commented Dec 11, 2017

Do you have an AppGlideModule or are you otherwise registering any components? Can you provide the implementation if you are?

@lam-amsiq
Copy link
Author

GlideModule:

@com.bumptech.glide.annotation.GlideModule
public class GlideModule extends AppGlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        builder.setIsActiveResourceRetentionAllowed(false);
    }
}

Usage:

ublic class DefaultImageLoader implements ImageLoader {

    @Override
    public void loadImage(String path, ImageView imageView, ImageType imageType) {
        GlideApp.with(imageView.getContext())
                .load(path)
                .apply(RequestOptions.centerCropTransform()
                        .placeholder(imageType == ImageType.FOLDER ? R.drawable.folder_placeholder : R.drawable.image_placeholder)
                        .error(imageType == ImageType.FOLDER ? R.drawable.folder_placeholder : R.drawable.image_placeholder)
                )
                .into(imageView);
    }
}

GlideApp is only used for managing local images and therefor it should not be related to this issue

@tristangrichard
Copy link

tristangrichard commented Dec 12, 2017

This bug seems to be related to network conditions. We have been able to reproduce it while loading images in a viewpager and go offline while swiping back and fourth.

Any progress?

This is our number one bug

@sjudd
Copy link
Collaborator

sjudd commented Dec 20, 2017

Maybe if you're able to attach a sample app where this is reproducible? I don't see anything obviously wrong with your code.

@sjudd
Copy link
Collaborator

sjudd commented Dec 20, 2017

Also are you using any networking libraries? Or just Glide's default?

@sjudd
Copy link
Collaborator

sjudd commented Dec 20, 2017

Internal bug is b/70869251

@sjudd sjudd added the bug label Dec 20, 2017
@tristangrichard
Copy link

We are not able to reproduce on every devices.
The one that can be crashed manually is an LG G3.
Glide's default, we use Retrofit and okHTTP for RestAPI calls only.

@tristangrichard
Copy link

@sjudd Seems to be fixed in 4.5.0

@sjudd
Copy link
Collaborator

sjudd commented Jan 8, 2018

Great then I think this was a duplicate of #2767.

@sjudd sjudd closed this as completed Jan 8, 2018
@camino2007
Copy link

camino2007 commented Feb 5, 2018

Still occurs in Glide 4.6.1

Only on devices below Android 5. I can reproduce in this way:
I have a ViewPager with Fragments which contain lists with images. When I start a fling on one Fragment and then switch to another Fragment the crash happens.

Please let me know if this is a new bug for you. If yes, I provide you a new issue with detailed information

The stack changed a little bit:

java.lang.IllegalStateException: Already released
at com.bumptech.glide.util.pool.StateVerifier$DefaultStateVerifier.throwIfRecycled(StateVerifier.java:46)
at com.bumptech.glide.load.engine.EngineJob.addCallback(EngineJob.java:125)
at com.bumptech.glide.load.engine.Engine.load(Engine.java:193)
at com.bumptech.glide.request.SingleRequest.onSizeReady(SingleRequest.java:451)
at com.bumptech.glide.request.target.ViewTarget$SizeDeterminer.getSize(ViewTarget.java:383)
at com.bumptech.glide.request.target.ViewTarget.getSize(ViewTarget.java:215)
at com.bumptech.glide.request.SingleRequest.begin(SingleRequest.java:264)
at com.bumptech.glide.manager.RequestTracker.runRequest(RequestTracker.java:42)
at com.bumptech.glide.RequestManager.track(RequestManager.java:634)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:618)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:583)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:576)

@sjudd
Copy link
Collaborator

sjudd commented Feb 5, 2018

@camino2007 please do file a new issue. If you're using a custom Target please include that as well.

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

No branches or pull requests

4 participants