Code Monkey home page Code Monkey logo

Comments (1)

Ereza avatar Ereza commented on July 17, 2024

Hi:

This is probably a concurrency issue with Bugsnag, they call back to the default handler, which makes CustomActivityOnCrash work, but they send the crash to their server on an asynchronous thread. If the sending fails, then they store it on disk for the next iteration.

If CustomActivityOnCrash is launched first (it's likely, because it's on the main thread), it kills the app and of course the asynchronous thread launched by Bugsnag is killed too.

What they should do (and I think that's what Crashlytics and ACRA do) is just write to disk on the main thread, then launch the new thread to their server. If the thread gets killed, it will be sent on the next app restart.

Actually you could probably fix this by making their ExceptionHandler call Client.notify(error, true) to make it blocking and do their things on the main thread. However, I can't verify that since I don't have a Bugsnag account.

I would suggest submitting a bug report or pull request to Bugsnag to fix this issue. This can also happen on any project with a default exception handler that just kills the app (that's what CustomActivityOnCrash ends up doing).

If you can't change the Bugsnag code, you can create a custom UnhandledExceptionHandler that calls back to the original handler, and set it after installing CustomActivityOnCrash. There, you can report a handled exception and wait for some milliseconds to give time for Bugsnag to process it. It's not the most elegant of solutions but it can be a workaround.

Check these classes if you want to take a deeper look at it:
https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/Bugsnag.java (initializes the client)
https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/Client.java (initializes the exception handler and does the send logic)
https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/ExceptionHandler.java (the actual exception handler)

I'll close this issue because there is nothing that the library can do to fix this problem. If you find out anything that could make this library handle better these situations please comment again and I'll reopen it.

from customactivityoncrash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.