-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Getting a crash in Glide 3.3 library #138
Comments
Please include your What I can see from the stacktrace is that you're using an async task to load something (list of wallpapers?) then in Now this can mean that you have an activity where the user presses a button, you fire an async task and then In general when you start an asynctask it should be cancelled in Hope this helps. If none of the above applies to you and your activity didn't leak then it can be a bug in Glide. Note: you can wrap stacktrace/code inside ``` on both sides to make it formatted. |
Glide.with(context).load(imageUrl).animate(R.anim.fade_in).into(imageView); I am passing activity context to it. I am starting async task from the onCreate and stopping in the OnDestroy, I have also cleared my listview in the onDestroy. It fetches data and send it to the activity. Activity is populating data in the listView. Wallpapermodule is one of the list item and is inherited from the LinearLayout. |
After you call |
Yes I am doing that. However rendering elements in the listview is not getting done by the asyncTask but by the adapter. Just want to update one thing, I was using Glide.with(Context) and was passing Activity context in it. Is it right way? Now I have started to use Glide.with(Activity). |
As long as the context was the Activity, there isn't any difference between the two. However, If the context was the application context, there is a difference as @TWiStErRob mentioned above. In general If you're loading images in an Activity, you should pass in the activity, if you're loading images in a Fragment you should pass in the Fragment, and if you're loading images for some reason other than displaying or using them in a particular view, you should pass in the application context. All that being said, I think there's probably a bug in your cancellation code, I'd guess @TWiStErRob is on the right track here. The framework method we're using to throw this exception has pretty clear documentation that it only returns true after the onDestroy call: http://developer.android.com/reference/android/app/Activity.html#isDestroyed(). Two things to try. Similarly you can try passing your activity down to wherever you call Let me know what you find and thanks for following up on this. |
Please re-open if you've tried the above and are still having issues. |
is there a reason why Glide doesn't always use the Application Context? The reason why people use libraries such as Glide is that they don't have to worry about the little details which can cause your application to crash. Thanks for your feedback! |
Please open a new issue, this is rather old, the current version is 3.6.1. |
correct, but I'm having the exact same issue (which is apparently not an issue, but a feature ;-), should I really open a new ticket? I'm only suggesting an improvement. |
It won't be an improvement because it would be against the resource sensitive nature of Android/Glide. Glide uses the object given in That little detail you mentioned can mean battery drain or memory leak in your app, which, thanks to Glide, is now surfaced. Why do you think that starting a load after the activity (where the image would be potentially displayed) has been destroyed is good idea? |
ok, that totally makes sense, but do you also get that crashing the app isn't a good solution too? I currently worked around this issue, but it isn't pretty. What's the 'official' way of handling these situations, because our app sometimes crashes because of the IllegalArgumentException, even when we think we handled all the edge cases. |
(the workaround I mentioned: check if the Activity is finishing, if so, stop loading the image) |
Is |
well, we are currently in our last sprint to release the application. When I've collected some more crash data, I'll try to share it with you. |
I'm having the exact same issue, right now, |
Please open a new issue with more information on your case, just write #138 to reference this issue. For example what are you doing as user just before that "all of a sudden" and what are you doing as a dev (code) just before that "all of a sudden". And of course the usual issue template |
Getting Same Problem. |
- Fixed crash due to error "You cannot start a load for a destroyed activity" See this link for more info on issue: bumptech/glide#138 - fix was in TileListRecyclerViewAdapter "Glide.with(mContext)" changed to "Glide.with(mContext.getApplicationContext())"
good |
Hi All,
I have seen one random crash in my application which was due to Glide image loading. Please find below the logs.
There is one more issue which I am facing. Sometime Glide is displaying random images. It is displaying those images which had been downloaded in other activity.
The text was updated successfully, but these errors were encountered: