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

Crash while cleaning up a transition that finished after Activity.onDestroy #265

Open
edenman opened this issue Jun 26, 2017 · 1 comment

Comments

@edenman
Copy link
Contributor

edenman commented Jun 26, 2017

1.0.0-alpha3

  1. user taps back button. we're on the loading screen, so we just pass along the call to Activity.onBackPressed()
  2. LoadingScreenView finishes loading its data, kicks off a call to transition from LoadingScreen->MapScreen
  3. Activity.onPause fires
  4. Activity.onDestroy fires, KeyManager.tearDown() is called
  5. transition finishes and tries to also tear down the LoadingScreen key, crashes

This is the first call to KeyManager.tearDown:

flow.KeyManager.decrementAndMaybeRemoveKey(KeyManager.java:131)
flow.KeyManager.tearDown(KeyManager.java:97)
flow.InternalLifecycleIntegration.onDestroy(InternalLifecycleIntegration.java:163)
android.app.Fragment.performDestroy(Fragment.java:2587)
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1121)
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1153)
android.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:2067)
android.app.FragmentController.dispatchDestroy(FragmentController.java:242)
android.app.Activity.performDestroy(Activity.java:6883)

And the actual crash:

                         E  Caused by: java.lang.NullPointerException: Attempt to read from field 'int flow.KeyManager$ManagedServices.uses' on a null object reference
                         E      at flow.KeyManager.decrementAndMaybeRemoveKey(KeyManager.java:131)
                         E      at flow.KeyManager.tearDown(KeyManager.java:97)
                         E      at flow.Flow$PendingTraversal.onTraversalCompleted(Flow.java:348)
                         E      at co.recharge.consumer.transition.FlowKeyChanger$startTransition$1.onNext(FlowKeyChanger.kt:336)
                         E      at co.recharge.consumer.transition.FlowKeyChanger$startTransition$1.onNext(FlowKeyChanger.kt:333)
                         E      at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:134)
                         E      at rx.internal.operators.OnSubscribeOnAssembly$OnAssemblySubscriber.onNext(OnSubscribeOnAssembly.java:124)
                         E      at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:224)
                         E      at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:107)

I'm not at all sure what the real fix is here.

@edenman edenman changed the title Crash while cleaning up a transition that was initiated after Activity.onPause Crash while cleaning up a transition that finished after Activity.onDestroy Jun 26, 2017
@sdelaysam
Copy link

sdelaysam commented Jul 22, 2017

Looks like duplicate of #194 ?
@loganj shouldn't KeyChanger or Dispatcher be lifecycle-aware to complete or cancel animated state transitions when host is paused? Is there any best-practice or example about this?

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

No branches or pull requests

2 participants