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

Handler still used after canceling #445

Open
arvola opened this issue Mar 17, 2014 · 6 comments
Open

Handler still used after canceling #445

arvola opened this issue Mar 17, 2014 · 6 comments

Comments

@arvola
Copy link

arvola commented Mar 17, 2014

I noticed that at times there are exceptions in the logs when navigating activities, even though the image downloads are being canceled prior.

I'm not very familiar with the inner workings of Picasso, but it would seem that BitmapHunter.hunt() does not check if it has been canceled while it's running, and so ends up trying to contact a dead handler at the end:

Handler (com.squareup.picasso.Stats$StatsHandler) {41b13d40} sending message to a Handler on a dead thread
    java.lang.RuntimeException: Handler (com.squareup.picasso.Stats$StatsHandler) {41b13d40} sending message to a Handler on a dead thread
            at android.os.MessageQueue.enqueueMessage(MessageQueue.java:196)
            at android.os.Handler.sendMessageAtTime(Handler.java:473)
            at android.os.Handler.sendMessageDelayed(Handler.java:446)
            at android.os.Handler.sendMessage(Handler.java:383)
            at com.squareup.picasso.Stats.processBitmap(Stats.java:104)
            at com.squareup.picasso.Stats.dispatchBitmapTransformed(Stats.java:59)
            at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:136)
            at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:83)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)

Since the exception is caught, it doesn't currently affect the app in any significant way, but I'd wager it'd still be better to avoid the exception in the first place.

Thoughts? I can make the necessary changes.

@dnkoutso
Copy link
Collaborator

Interesting... have you invoked shutdown() in your instance?

@arvola
Copy link
Author

arvola commented Mar 17, 2014

No, we are using the singleton, which I assume doesn't need shutdown() between activities.

@dnkoutso
Copy link
Collaborator

You are correct. You shouldn't need shutdown. Besides you cant invoke shutdown on the singleton instance it will crash.

I will need to investigate. Thanks!

@dnkoutso dnkoutso added this to the Picasso Next milestone Mar 17, 2014
@dnkoutso dnkoutso modified the milestones: Picasso 2.4, Picasso Next May 27, 2014
@dnkoutso
Copy link
Collaborator

Will investigate for 2.4.

@dnkoutso dnkoutso modified the milestones: Picasso Next, Picasso 2.4 Oct 23, 2014
@dnkoutso dnkoutso modified the milestones: Picasso 2.5, Picasso Next Dec 10, 2014
@dnkoutso dnkoutso modified the milestones: Picasso Next, Picasso 2.5 Dec 23, 2014
@dnkoutso
Copy link
Collaborator

@arvola does this still occur to you? I am moving to Picasso Next. A sample app demonstrating this would be great.

@arvola
Copy link
Author

arvola commented Dec 23, 2014

I'm not sure, but I will take a look and see if I can create a sample.

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

No branches or pull requests

3 participants