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

Object watcher description #1658

Merged
merged 1 commit into from
Dec 9, 2019
Merged

Object watcher description #1658

merged 1 commit into from
Dec 9, 2019

Conversation

pyricau
Copy link
Member

@pyricau pyricau commented Dec 3, 2019

Originally KeyedWeakReference had a "name" field that wasn't used out of the box but could be useful to add identifying information. This PR renames it to "description" and uses it for automatic watching, surfacing more clearly why an object is watched.

Related to #1656

@pyricau pyricau added this to the Next release milestone Dec 3, 2019
@@ -35,7 +35,7 @@ internal class AndroidXFragmentDestroyWatcher(
) {
val view = fragment.view
if (view != null && configProvider().watchFragmentViews) {
objectWatcher.watch(view)
objectWatcher.watch(view, "Fragment received Fragment#onDestroyView() callback")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one confused me too when I encountered a leak in our demo app. Might worth adding more info, e.g. "Fragment received Fragment#onDestroyView() callback: fragment instance is kept, but its view will be destroyed. All references to the view should be cleared to prevent leaks." Basically, something that tells people that fragment is staying around for a while, but the view is not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, and updated docs as well

@Armaxis
Copy link
Member

Armaxis commented Dec 3, 2019

With these changes the upgrade guide will need to be updated too, so that it doesn't override a deprecated method:
https://square.github.io/leakcanary/upgrading-to-leakcanary-2.0/#option-2-make-your-own-objectwatcher-interface

@pyricau pyricau force-pushed the py/watch_description branch from c47c777 to f18c190 Compare December 4, 2019 00:13
Originally KeyedWeakReference had a "name" field that wasn't used out of the box but could be useful to add identifying information. This PR renames it to "description" and uses it for automatic watching, surfacing more clearly why an object is watched.

Related to #1656
@pyricau pyricau force-pushed the py/watch_description branch from f18c190 to 23bd187 Compare December 9, 2019 21:25
@pyricau pyricau merged commit 599011e into master Dec 9, 2019
@pyricau pyricau deleted the py/watch_description branch December 9, 2019 23:50
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

Successfully merging this pull request may close these issues.

2 participants