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
Improve detection of leaky receivers? #2091
Comments
It looks like the entries are removed here: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/app/ActivityThread.java;l=5190;drc=af6f90bbf1c6155a1ff55a63c1e1138d345da8bb |
Here's a repro:
Activity receiver leaks aren’t supposed to happen. Sometimes after Activity.onDestroy(), there’s a “final cleanup” callback that ensures all registered receivers and unregistered, and drops a message in logcat yelling at you because you should have done that already. However, here, we’re using a post delayed so we are registering to the destroyed activity AFTER the cleanup has happened. The proper behavior would likely be for Android to throw an exception (don’t register on a destroyed activity) or at least a log + no-op. However this goes through just fine. The receiver itself does not hold any reference to the activity, which will make that leak really hard to track, because this bad registration won’t be visible anywhere in the leak trace: |
@pyricau can the same be done for services?
|
This comes from Stack Overflow: https://stackoverflow.com/q/66611127/703646
The leaktrace looked like this:
Apparently this was caused by a receiver registered twice. Worth trying to repro and then see how we could make leakcanary provide a better report for these.
The text was updated successfully, but these errors were encountered: