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

Infinite loop if Dialog Option is choosen and the app crashes on onResmue Method of a Activity #42

Closed
snakevalley opened this issue Jan 9, 2013 · 12 comments
Assignees
Milestone

Comments

@snakevalley
Copy link

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.

@william-ferguson-au
Copy link
Member

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

@snakevalley
Copy link
Author

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:

  1. App is launched, MainActivity is shown
  2. Click on a link, second Activity is started by an Intent
  3. In onResume() of the second Activity an exception is raised

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.

@william-ferguson-au
Copy link
Member

So if you comment out ACRA#init in your Application#onCreate you get totally different behaviour that when ACRA#init has been invoked?

@snakevalley
Copy link
Author

Exactly. Without the ACRA.init(); call the application "crashes" like expected. With the ACRA.init() line it comes to the infinite loop.

    Gesendet: Donnerstag, 10. Januar 2013 um 22:44 UhrVon: william-ferguson-au <notifications@github.com>An: ACRA/acra <acra@noreply.github.com>Cc: snakevalley <jochenzink84@web.de>Betreff: Re: [acra] Infinite loop if Dialog Option is choosen and the app crashes on onResmue Method of a Activity (#42)


    So if you comment out ACRA#init in your Application#onCreate you get totally different behaviour that when ACRA#init has been invoked?


          —
          Reply to this email directly or view it on GitHub.

@william-ferguson-au
Copy link
Member

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.

@KevinGaudin
Copy link
Member

I merged the PR today on the master branch.
Tested on Nexus One (2.3.7) Galaxy Tab 10.1 (4.0.4) and SDK (4.1.2).

@KevinGaudin
Copy link
Member

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.

@william-ferguson-au
Copy link
Member

I'm not sure this is going to work.
It requires all of your Actvities to extend from the one in the
org.jraf.android.util.activitylifecyclecallbackscompat.app
package.

If that isn't done then you won't get the Application life cycle callbacks
occurring.

William

On Wed, Jan 30, 2013 at 8:44 AM, KevinGaudin notifications@github.comwrote:

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.


Reply to this email directly or view it on GitHubhttps://github.com//issues/42#issuecomment-12863034.

@KevinGaudin
Copy link
Member

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.

@william-ferguson-au
Copy link
Member

But we get that without adding a dependency on this library.

On Wed, Jan 30, 2013 at 8:56 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.


Reply to this email directly or view it on GitHubhttps://github.com//issues/42#issuecomment-12863680.

@KevinGaudin
Copy link
Member

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.

@william-ferguson-au
Copy link
Member

Ahhh, I missed "since Android API 7 or such, dalvik doesn't complain about
uknown class at load time, until it tries to execute it.". I didn't realise
it was an API 7 and up thing.

Fair enough then.

On Wed, Jan 30, 2013 at 9:12 AM, KevinGaudin notifications@github.comwrote:

I was concerned about having to raise the minimum API level to 7 for
integrating ACRA (remember #41 #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 crashes 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.


Reply to this email directly or view it on GitHubhttps://github.com//issues/42#issuecomment-12864345.

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

No branches or pull requests

3 participants