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

Fixed a fragment view leak by using DataBinding-ktx #230

Closed

Conversation

TomoyaShibata
Copy link
Contributor

Issue

Overview (Required)

  • References to view remain unintentionally when add a fragment to a backstack.
  • You can destroy the reference by setting binding = null in Fragment#onDestroyView lifecycle, but introduced wada811/DataBinding-ktx which does it automatically.

Links

@takahirom
Copy link
Member

👀

@takahirom
Copy link
Member

DataBinding-ktx is awesome🔥
But if we want to use like recyclerview adapter. We should assign null
How about this?
https://github.com/android/architecture-components-samples/blob/9826b59956eb93c9e627bdf16a19a1c8bc28ce14/GithubBrowserSample/app/src/main/java/com/android/example/github/util/AutoClearedValue.kt#L31-L40
I think it is OK to use DataBinding-ktx , but I am thinking.🤔

@TomoyaShibata
Copy link
Contributor Author

TomoyaShibata commented Jan 15, 2020

AutoClearedValue awsome idea too! I will try it's approach.

If you adopt AutoClearedValue approach, do you want to unify it to AutoClearedValue?

Another great feature of DataBinding-ktx is the automatic invocation of setLifecycleOwner, but this is not required for this app. So it is possible to unify to AutoClearedValue.

@TomoyaShibata
Copy link
Contributor Author

Add what you care about. 📝

There are comments in the source code that can create situations that cause NPE to be thrown, and This tweet is have mentioned it. 👀

https://twitter.com/wada811/status/1217361894224220160

@takahirom
Copy link
Member

Thank you for investigate 🙏
If you have time, can you create AutoClearedValue version PR?
I don't think it's a big problem. 🙇

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

Successfully merging this pull request may close these issues.

Fix fragment view leaks
2 participants