mozilla-mobile / android-components

⚠️ This project moved to a new repository. It is now developed and maintained at: https://github.com/mozilla-mobile/firefox-android
https://github.com/mozilla-mobile/firefox-android
Mozilla Public License 2.0
2.02k stars 472 forks source link

Improve tooling around finding leaks #3888

Closed pocmo closed 5 years ago

pocmo commented 5 years ago

We have been investigating and fixing leaks in our apps and components. Hunting them and fixing them is always challenging and time consuming. The scary part is that we often did not notice them for a long time and "randomly" stumbled upon them. We desperately need tooling to discover them automatically and way earlier.

The only tool I know is LeakCanary. It's primary use case is detecting leaks while using the app.

Ideally we'd be able to detect such leaks in automation and in the best case can correlate them with a specific commit that introduced them.

┆Issue is synchronized with this Jira Task

pocmo commented 5 years ago

We could also look at custom solutions - maybe in conjunction with LeakCanary. In our browser apps we primary care about Activities, Fragments, EngineSessions, GeckoSessions, ...

Amejia481 commented 5 years ago

We could take a look at LeakCanary 2 looks pretty promising:

Talk about LeakCanary 2 https://youtu.be/LEX8dn4BLUw?list=PLn7H9CUCuXAu5r4kT8RcK8B2GuBqMODX3

pocmo commented 5 years ago

Yeah, just saw this too, this looks promising: https://speakerdeck.com/pyricau/leakcanary-2?slide=28

pocmo commented 5 years ago

LeakCanary depends on androix-core 2.0 alpha something. Can't use it yet. :|

pocmo commented 5 years ago

The old version of LeakCanary also supports running in instrumentation. I'll try experimenting with that.

pocmo commented 5 years ago

Screenshot_2019-07-24 Test results - Class org mozilla samples browser SmokeTests

Yay, I'm able to reproduce #3887 with a ui test and leak canary.

pocmo commented 5 years ago

Closing this for now: We now have a LeakDetectionRule that we can use in AC and apps. And we have an additional UI test that protects us against a leak we saw in the past.