-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Crash during espresso tests #1336
Comments
We are using the 2.0-alpha1 version. |
Any chance you have a heap dump that could help me reproduce this? This is happening because LeakCanary found 0 potential leak cause, which likely means the entire leak trace is considered reachable or unreachable, or there are inconsistencies. This is usually due to reachability inspectors reaching conflicting conclusions. I've added rules for alpha-2 that will correctl detect and solve conflicts, which means this shouldn't happen in the next release. That being said I'd love to know what the inspectors are getting wrong, a heap dump would help |
I have a log of the leak, I don't have a dump. I can try to add saving of the dump, let me find how to do it. |
One thing that's surprising to me: are you not using the instrumentation test listener? It looks like you're running normal LeakCanary in tests instead, which means the tests might be randomly freezing on heap dumps. |
Good comment - I didn't add no-op dependency to instrumental tests. That is why "normal" LeakCanary also operates while running the UI tests. Let me do it and see what happens. |
Oh wait, you're right and I actually have this already. |
Then I don't know what could be the issue. |
The crash shows that AnalysisResultService was started. AnalysisResultService should not start when FailTestOnLeakRunListener is set up: FailTestOnLeakRunListener#testRunStarted calls InstrumentationLeakDetector.Companion#updateConfig which configures LeakCanary to not dump the heap. Unless you're overriding that configuration somewhere else in the code? |
Yes, we do, on the app start:
|
But this also means that if I remove the listener from UI test I have somehow suppress LeakCanary from running in the UI tests since there is no-op. Let me add in our test runner config modification as well. |
* Combined leaking information from inspectors to solving conflicts while keeping all reasons * Made reason from view leak inspector more obvious, and added label data about internals * Moved reachability into LeakTraceElement * Reachability renamed to LeakNodeStatus and leaking / not leaking * ReachabilityInspector and Labeler are now functions with type aliases Related to #1336: should fix the crash, though it's still unclear why AppCompatButton was a gc root there.
* Combined leaking information from inspectors to solving conflicts while keeping all reasons * Made reason from view leak inspector more obvious, and added label data about internals * Moved reachability into LeakTraceElement * Reachability renamed to LeakNodeStatus and leaking / not leaking * ReachabilityInspector and Labeler are now functions with type aliases Related to #1336: should fix the crash, though it's still unclear why AppCompatButton was a gc root there.
I also have CI builds randomly fail because of leak canary (latest alpha) breaking Espresso tests. E.g.
Is there a way I could disable leak canary 2.x for tests now that no-op is gone? |
If you have own test runner then you can try next code:
|
Sorry, where should I put this code? You wrote a custom AndroidJUnitRunner? |
Sound like you don't have it. Then you should add new class to espresso test:
Then you should also define it in your
And then, in this runner, you should override |
This should be fixed in the next release, let me know if not. |
We have a crash:
It happened during our automated tests and I see from the log that LeakCanary detected a leak.
The text was updated successfully, but these errors were encountered: