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

read logcat logs in nonblocking mode with end timeout #466

Merged
merged 7 commits into from
Sep 7, 2016
Merged

read logcat logs in nonblocking mode with end timeout #466

merged 7 commits into from
Sep 7, 2016

Conversation

c-romeo
Copy link
Contributor

@c-romeo c-romeo commented May 30, 2016

I encounter and issue with handleSilentException and ReportField.LOGCAT on Lenovo TAB 2 A8-50F.
It appears that when an ProgressDialog is shown a lot of useless info are spitted to the logs and ACRA spends couple of minutes to receive logs and send report due the fact that reading from InputStream is done in a blocking way.

I think is better to have at least an empty log info than a lots of useless logs due the fact that Stream is blocked for writing.

Also for my particular context handling ACRA's sending exception in another thread helped me, and received some info due the fact ProgressDialog is closed immediately after.
new Thread(new Runnable() { @Override public void run() { ACRA.getErrorReporter().handleSilentException(e); } }).start();
the_culprit.txt

@william-ferguson-au
Copy link
Member

What version of ACRA was this for?

@c-romeo
Copy link
Contributor Author

c-romeo commented May 30, 2016

I reproduce it with version 4.8.5 / 4.9.0 rc 2; not sure about 4.6.3, a user reported similar behaviour but I didn't investigated than

@c-romeo
Copy link
Contributor Author

c-romeo commented May 30, 2016

Patch was tested with 4.9.0 rc 2

String line;
final List<String> buffer = limit == NO_LIMIT ? new LinkedList<String>() : new BoundedLinkedList<String>(limit);
long end = System.currentTimeMillis() + READ_TIMEOUT;
while ((System.currentTimeMillis() < end)) {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this mean that it will always block for 3 seconds?

Copy link
Contributor Author

@c-romeo c-romeo Jun 4, 2016

Choose a reason for hiding this comment

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

Yes, I've added a read timeout limit. Not sure if this should be exposed to ACRAConfiguration.
In my tests if timeout was reached in few seconds I received on remote server logs with empty logcat field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if a developer don't want any delay on main / exception thread, acra's work should be done in a separate thread. For the moment I use a helper method in which I use a Runnable and start a new thread; again, not sure if a queue should be use.

Copy link
Member

Choose a reason for hiding this comment

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

My point is, is that it's not a timeout.
This read will block for exactly 3 seconds regardless of whether there is any log to read.

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 point. this is the fix
if ((line = nonBlockingReader.readLine()) != null) { if (filter.apply(line)) { buffer.add(line); } } else { break; }

@william-ferguson-au
Copy link
Member

NB when you submit a pull request, always submit it from a branch so that you don't risk polluting it with any other changes you might make.

@c-romeo
Copy link
Contributor Author

c-romeo commented Jun 4, 2016

This means that I should do something next?

@F43nd1r
Copy link
Member

F43nd1r commented Jun 4, 2016

If this runs into timeout, will the newest or the oldest logs miss?

BTW: I wouldn't name this method Async, because this normally means that it returns asynchronous. Something more descriptive like NonBlocking would fit better.

I also think this might not be a good idea as default, maybe an opt-in option for it would be better.

@c-romeo
Copy link
Contributor Author

c-romeo commented Jun 6, 2016

If runs in timeout it will

  • be missing all the log (most of my cases, and I'm very happy with the fix even if reports lacks of logcat logs I still receive callstack, custom fields...)
  • or if aggressive logging will start while acra receive some logs only the oldest will be sent.

@F43nd1r
Copy link
Member

F43nd1r commented Jun 6, 2016

I just checked out your master for testing purpose. It does not compile. I think you forgot to commit the addition of local attributes in ACRAConfiguration and ConfigurationBuilder.

@c-romeo
Copy link
Contributor Author

c-romeo commented Jun 7, 2016

Fixed

@william-ferguson-au william-ferguson-au merged commit 3ac99e6 into ACRA:master Sep 7, 2016
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.

3 participants