You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LeakCanary has a check to avoid checking for leaks in tests, but it's done later in the process when checking for retained objects, and LeakCanary still installs the default InstallableWatchers in test builds.
This has a side effect, as the ServiceWatcher swaps the instance of IActivityManager with a new proxy instance, it causes an issue with Fastlane's screengrab, as it relies on reflection to access the IActivityManager instance to handle Locale switching, this is the cause of this fastlane/fastlane#19521 (at least it's for us, as there may be other libraries that cause it too).
To solve this, currently, we are switching to the leakcanary-android-core artifact, and handling LeakCanary's initialization manually, but it would be awesome if LeakCanary did this automatically, maybe by adding the check to the MainProcessAppWatcherInstaller? 🤔
This is a continuation of the discussion started in #1552
The text was updated successfully, but these errors were encountered:
hichamboushaba
changed the title
Provide a way to avoid installing the default InstallableWatchers in unit tests
Provide a way to avoid installing the default InstallableWatchers in tests
Jul 14, 2022
Thanks for the bug report. The thing that makes this tricky is that we default to disabling LeakCanary in test, but we also want people to leverage the instrumentation test artifact and actually do detect leaks in test (just differently), and in that case we do want the service watcher to be installed.
Note that the change could also be done on the fast lane side, by getting method from the proper real classes based on API levels instead of retrieving amnClass
I'll trust your judgment here, if you believe this behavior should be kept in the library, feel free to close the ticket, there is always the solution of using leakcanary-android-core and starting LeakCanary manually.
LeakCanary has a check to avoid checking for leaks in tests, but it's done later in the process when checking for retained objects, and LeakCanary still installs the default
InstallableWatcher
s in test builds.This has a side effect, as the ServiceWatcher swaps the instance of
IActivityManager
with a new proxy instance, it causes an issue with Fastlane'sscreengrab
, as it relies on reflection to access theIActivityManager
instance to handle Locale switching, this is the cause of this fastlane/fastlane#19521 (at least it's for us, as there may be other libraries that cause it too).To solve this, currently, we are switching to the leakcanary-android-core artifact, and handling LeakCanary's initialization manually, but it would be awesome if LeakCanary did this automatically, maybe by adding the check to the
MainProcessAppWatcherInstaller
? 🤔This is a continuation of the discussion started in #1552
The text was updated successfully, but these errors were encountered: