Skip to content
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

Toast rather than crash when sharing giant traces #31

Merged
merged 1 commit into from
Apr 20, 2017
Merged

Toast rather than crash when sharing giant traces #31

merged 1 commit into from
Apr 20, 2017

Conversation

stkent
Copy link
Contributor

@stkent stkent commented Mar 20, 2017

Fixes #25.

@pedrovgs unlike #30, there are several fairly different ways this issue could be addressed. I've included one in this PR, but am more than happy to discuss and make changes if you'd prefer a different solution. (For example, we could build an automatic retry with truncated traces into the shareTraces method.)

@pedrovgs
Copy link
Owner

Hi @stkent, sorry for the late response.

I think this implementation good but we should not show an error to the user if the trace is too long. We should measure the max trace size taking a look at the original implementation and don't try to send more traces than the one we can share depending on the OS version. What do you think? Can we update this PR implementing this change?

@stkent
Copy link
Contributor Author

stkent commented Apr 16, 2017

I'm not sure there's a known per-Intent limit available for us to read at runtime (see e.g. http://stackoverflow.com/questions/12496700/maximum-length-of-intent-putextra-method-force-close). The empirical "type-then-catch-the-exception" method is a way of working around that uncertainty. If you know something I don't, however, please point me to a reference in the docs!

@pedrovgs
Copy link
Owner

After researching this issue seems that there is a limit depending on the Android SDK being used and device close to 1 MB of bytes being sent using a Parcelable instance.

Here you have some references:

Based on this information, I'd catch the exception and if the limit is exceeded we should try to share just the last 100kb of traces. Even when the limit seems to be 1MB there is a blog post saying that it could be closer to 500kb so I think the last 100kb should be enough information. What do you think @stkent? Can we update this PR implementing this behavior?

@stkent
Copy link
Contributor Author

stkent commented Apr 17, 2017

Awesome, yes, I think that behavior should be possible! I'll try today and let you know how it goes :)

@pedrovgs
Copy link
Owner

Great! Let me know once the code is ready and I'll take a look again 😃

@stkent
Copy link
Contributor Author

stkent commented Apr 17, 2017

@pedrovgs let me know what you think of the updated suggestion!

/*
* Limit trace size to between 100kB and 400kB, since Unicode characters can be 1-4 bytes each.
*/
String truncatedTraces = fullTraces.substring(0, Math.min(100000, fullTraces.length()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this substring call you are going to take the first part of the traces but the most relevant one is the last part of the traces content. Am I wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed!

@pedrovgs
Copy link
Owner

Great @stkent! Thank you so much for your time and patience 😃 I'm merging this PR and releasing a new version!

@pedrovgs pedrovgs merged commit 641619f into pedrovgs:master Apr 20, 2017
@stkent
Copy link
Contributor Author

stkent commented Apr 20, 2017

No problem, thanks for maintaining a great library!

@stkent stkent deleted the fix-25 branch April 20, 2017 14:56
@pedrovgs
Copy link
Owner

I've just released the new version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants