-
Notifications
You must be signed in to change notification settings - Fork 321
Increase InstrumentationResultPrinter.MAX_TRACE_SIZE #711
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
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Damn, I did sign the corporate CLA with my work email but Github online edit picked my personal email. |
@brettchabot Friendly bump. This would be a welcome change also for projects using |
@@ -45,7 +45,7 @@ | |||
|
|||
private static final String TAG = "InstrumentationResultPrinter"; | |||
|
|||
@VisibleForTesting static final int MAX_TRACE_SIZE = 32 * 1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned this change is risky. It looks like the reason this limit exists is to prevent going over the binder IPC limit. It would seem like increasing the trace size would increase the chances of that occurring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the binder maximum size was 1 MB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but I think it is possible that multiple stack traces will get sent in one binder transaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any value here is risky, in any direction we go. Decreasing max means shorter stacktraces => Espresso is less useful. Increasing the max means more risk of hitting the binder max.
What if this didn't already have a value today, how would we pick a value? 65,536 bytes is super conservative, but 131,072 bytes is also very conservative. To send multiple stacktraces at the same time you'd need to run tests in parallel and you'd need them to fail and you'd need long stacktraces for each. Isn't that a bit far fetched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am under the impression that multiple stack traces can get sent in one transaction even under normal conditions. Even with this trace limit in place, there are user complaints about binder size transaction errors.
#269
Long term we hope to move away from using binder to communicate test results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be hard to impose a limit on the aggregated size rather than individuals? If the cumulative stack trace size is big in one binder transaction, then stop adding more stack traces. This way, the common usefulness will increase (developer running a single test, tying to reproduce an issue and not seeing stack currently), while other cases will have more data too, but with some stacks fully missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed change is targeting InstrumentationResultPrinter
, not OrchestrationResultPrinter
/OrchestrationXmlTestRunListener
which the linked issues IMO clearly shows has issues.
Also OrchestrationResultPrinter
/OrchestrationXmlTestRunListener
do not impose any limits on the MAX_TRACE_SIZE although the OrchestrationResultPrinter
-javadoc states:
...
A line by line reimplementation of {@link
androidx.test.internal.runner.listener.InstrumentationResultPrinter}
...
(maybe they actually should)
And they have no dependency on InstrumentationResultPrinter
from what I can tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah cool. Thanks for all the investigation everyone. There have been reports of non-orchestrator-using users hitting binder transaction issues as well, but I suspect they were making heavy use of metrics. This change sounds reasonable but I'd like to do a bit more investigation with those users. I'm pretty slammed this week but will report back next week.
@pyricau would you be able to sign the CLA? thanks |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Amended the commit to replace author with my work email, CLA ✅ |
TAG, | ||
String.format("Stack trace too long, trimmed to first %s characters.", MAX_TRACE_SIZE)); | ||
trace = trace.substring(0, MAX_TRACE_SIZE) + "\n"; | ||
trace = failure.getTrimmedTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately it looks like getTrimmedTrace is only available in JUnit 4.13. Androidx.test still uses junit 4.12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Should I remove it? Add a reflection check to see if the method is available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a failure at the end of a test, the performance penalty shouldn't matter. Your call!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove for now, but add a TODO to use it.
I have always wanted to see stack traces trimmed and I'm stoked to see such a method available, but JUnit upgrades can be onerous , so let's pursue that separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #729
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated branch with just the value change.
This change increases InstrumentationResultPrinter.MAX_TRACE_SIZE from 65,536 bytes to 131,072 bytes, giving more room for long stacktraces (think RxJava and also view hierarchy logged as part of the trace message).
Also attempts to fallback to getTrimmedTrace() before actively trimming the trace at a random point.