Is this a bug in ImageViewTarget?
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
I recently debug an app that loads image with Glide. The app implments a method to load image by folowing code:

The `ResourceBuilder.into( ImageView view )` method provided by Glide further invokes `ResourceBuilder.into( v target, RequestListener targetListener,RequestOptions options)` with a new created `ImageViewTarget `via :

In the invoked method, Glide would first tries to clear the `target`

the `clear()` method would finally call the `TargetTracker.untrack(Target target)` method to remove the target.

However, the target is obtained by `GlideContext.buildImageViewTarget()`, which create a new Target object when be called.
So, the new `target ` instance cannot be found in the `targets`, even if there is one Target in `targets` points to the same View.
And after running the app for a period of time, the `targets` would contains a lot of instances of ImageViewTarget, many of which point to the same View object.
I think this might be a problem, and `ImageViewTarget` should override the `hashCode()` and `equals()` methods based on the View object it contains, so as to be uniquely identified.
For example, I got 50 instances in `targets` with Glide:

After I overrided the `hashCode()` and `equals()` methods, I got only 13 instances in `targets`:

Contributor guide
Assessment
This issue has not been assessed yet.