lukaspili / Mortar-architect

[DISCONTINUED] Navigation stack for Mortar. Alternative to Flow. Focuses on Mortar scopes, simplicity, seamless integration and killing boilerplate code.
MIT License
164 stars 12 forks source link

Rare crash that appears to be caused by onDestroy not getting called #26

Open grundleborg opened 8 years ago

grundleborg commented 8 years ago

I'm seeing a weird crash in a mortar-architect powered app. It's occurring occasionally for about 10% of the app's user base, and unfortunately I haven't been able to reproduce the crash myself on any device. The stack trace looks roughly as follows:

IllegalArgumentException
Current navigator view not null, did you forget to detach the previous view?
architect.Preconditions in checkNull at line 23 (application)
architect.Presenter in attach at line 56 (application)
architect.NavigatorLifecycleDelegate in onCreate at line 44 (application)
architect.commons.ActivityArchitector in onCreateNavigator at line 38 (application)
example.my.app.MainActivity in onCreate at line 98 (application)
android.app.Activity in performCreate at line 6876
android.app.Instrumentation in callActivityOnCreate at line 1135
android.app.ActivityThread in performLaunchActivity at line 3206
android.app.ActivityThread in handleLaunchActivity at line 3349
android.app.ActivityThread in access$1100 at line 221
android.app.ActivityThread$H in handleMessage at line 1794
android.os.Handler in dispatchMessage at line 102
android.os.Looper in loop at line 158
android.app.ActivityThread in main at line 7224
java.lang.reflect.Method in invoke
com.android.internal.os.ZygoteInit$MethodAndArgsCaller in run at line 1230
com.android.internal.os.ZygoteInit in main at line 1120

The code of my MainActivity is more or less identical to that shown in the mortar-architect sample app.

So far, the best explanation I've been able to come up with is that in some weird circumstances MainActivity::onDestroy() is not getting called, and so when MainActivity::onCreate() next gets called, the call to Navigator.find() is retrieving a Navigator that is already activated, thus the precondition check failed. What I can't really figure out is: 1) Is this actually a valid explanation? 2) What is the appropriate way to work around it?

lukaspili commented 8 years ago

I saw that issue on a project. Be sure that your single activity has the lanchMode set to singleTask.

<activity
            android:name="my.Activity"
            android:label="@string/app_name"
            android:launchMode="singleTask" />
lukaspili commented 7 years ago

Also, what version of architect are you on?