-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Infinite loop if Dialog Option is choosen and the app crashes on onResmue Method of a Activity #42
Comments
This is not specific to the Dialog option of ACRA, or ACRA for that matter. On application crash the Android framework will attempt to restart your app and the Activity last shown. So if your Activity throws an Exception in onResume then it will get into an unbounded restart loop. William |
It is specific to the ACRA lib and not to the Android System. If I don't use ACRA I get the normal force close Dialog of the Android System. Android also did not restart the Activity which has crashed. It tries to start the last working Activity. For example:
Without ACRA, the force close Dialog is shown and the User comes back to the MainActivity. With ACRA, it comes to an infinite loop. onResume of the second Activity is called in a loop. |
So if you comment out ACRA#init in your Application#onCreate you get totally different behaviour that when ACRA#init has been invoked? |
Exactly. Without the ACRA.init(); call the application "crashes" like expected. With the ACRA.init() line it comes to the infinite loop.
|
OK, I have managed to replicate and have sent Kevin a pull request with changes that will work for Android 4.0+ (earlier versions will continue to get the current behavior unless someone can solve X). The solution essentially listens for Activity lifecycle events and keeps track of the last Activity that was created. And on crash explicitly finishes that Activity before killing the Process (which will attempt to recreate the entire Task stack). X: To be available on versions < 4.0 we need some way of working out which Activity was last created. |
I merged the PR today on the master branch. |
I'm integrating some code from https://github.com/BoD/android-activitylifecyclecallbacks-compat to allow the use of the new API without losing the compatibility with the oldest android versions. |
I'm not sure this is going to work. If that isn't done then you won't get the Application life cycle callbacks William On Wed, Jan 30, 2013 at 8:44 AM, KevinGaudin notifications@github.comwrote:
|
Absolutely, my idea was to integrate the abstraction layer to allow ACRA to still be compatible with older android versions without benefiting from the activity lifecycle tracking. For apps before ICS, ACRA will behave like it always has. Starting with ICS, the latest activity will be destroyed. |
But we get that without adding a dependency on this library. On Wed, Jan 30, 2013 at 8:56 AM, KevinGaudin notifications@github.comwrote:
|
I was concerned about having to raise the minimum API level to 7 for integrating ACRA (remember #41 ). Before API level 7, ACRA.init() crashes with a verify error. I know there are now less than 1% of devices running cupcake or donut... but... well... that was itching. :-) Anyway, this is not really a dependency with another lib. It's the inclusion of 5 abstraction/wrapping classes which mimic the new API so that it does not crash on those old android versions. There is now a dev branch, I just committed these changes in that branch if you want to have a look. |
Ahhh, I missed "since Android API 7 or such, dalvik doesn't complain about Fair enough then. On Wed, Jan 30, 2013 at 9:12 AM, KevinGaudin notifications@github.comwrote:
|
Acra Version 4.4.0
Tested on Nexus 7 with Android 4.2.1
If the Dialog option is enabled and the Activity crashes in the onResume() Method, a infinite loop starts. For some reason, the onResume Method is called again and again and everytime the Exception of the first crash is thrown, Acra catches it and again, onResume is called. Only chance to stop it, is to go to the home screen.
I believe (not sure how it is implemented), that the Dialog is created in the context of the current activity. So, the crashed Activity is started again and will fail again in the onResume method.
The text was updated successfully, but these errors were encountered: