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

NPE on presenter.destroy() in MviConductorLifecycleListener postDestroy() #38

Open
abyrnes opened this issue Aug 30, 2018 · 4 comments
Open

Comments

@abyrnes
Copy link

abyrnes commented Aug 30, 2018

I found the following crasher. No repro steps unfortunately. But hopefully someone has an idea as to why it's happening:

com.hannesdorfmann.mosby3.MviConductorLifecycleListener.postDestroy (MviConductorLifecycleListener.java:133)
  com.bluelinelabs.conductor.Controller.performDestroy (Controller.java:1076)
  com.bluelinelabs.conductor.Controller.removeViewReference (Controller.java:972)
  com.bluelinelabs.conductor.Controller.destroy (Controller.java:1097)
  com.bluelinelabs.conductor.Controller.destroy (Controller.java:1082)
  com.bluelinelabs.conductor.Backstack.pop (Backstack.java:61)
  com.bluelinelabs.conductor.Backstack.popAll (Backstack.java:82)
  com.bluelinelabs.conductor.Router.destroy (Router.java:220)
  com.bluelinelabs.conductor.ControllerHostedRouter.destroy (ControllerHostedRouter.java:88)
  com.bluelinelabs.conductor.Controller.destroy (Controller.java:1093)
  com.bluelinelabs.conductor.Controller.activityDestroyed (Controller.java:859)
  com.bluelinelabs.conductor.Router.onActivityDestroyed (Router.java:558)
  com.bluelinelabs.conductor.ActivityHostedRouter.onActivityDestroyed (ActivityHostedRouter.java:61)
  com.bluelinelabs.conductor.internal.LifecycleHandler.destroyRouters (LifecycleHandler.java:209)
  com.bluelinelabs.conductor.internal.LifecycleHandler.onDestroy (LifecycleHandler.java:160)
  android.app.Fragment.performDestroy (Fragment.java:2587)
@abyrnes
Copy link
Author

abyrnes commented Aug 30, 2018

I suppose this could be related to #36

@sockeqwe
Copy link
Owner

Thanks for reporting. Yes it might be related to #36 or to #26

I'm not sure how this can happen, because it seems that presenter is null. Do you have a controller that doesn't have a UI (returning null from Controller.onCreateView())? Or maybe this happens if the user clicks back button fast enough before the View has been created because Presenter gets created after Controller.onCreateView().

Any idea how to reproduce this?

@abyrnes
Copy link
Author

abyrnes commented Sep 4, 2018

I've been able to resolve the issue on my side: We had a case where a child router was being used and the root was being set without checking if it already had a root after process death. Simply making sure that the root was only being set if necessary fixed the problem.

Not sure if any extra action should be taken here

@Anfet
Copy link

Anfet commented Feb 21, 2020

If possible I can bump up this topic.

I have an interesting situation.
ViewPagerControllerA > PageA pushes ViewPagerControllerB > Page B
...
Activity is killed (Dunno how it happens, but I reproduced it by setting "kill activities" in developer options)
All controllers are being destroyed
....
Activity is restored
...
Attempt to invoke interface method 'void com.hannesdorfmann.mosby3.mvi.MviPresenter.destroy()' on a null object reference
Becase view hierarchy is restoring to ViewPagerControllerB, while trying to remove ViewPagerControllerA which doesn't exist anymore.
Am I correct in this assumption?

I guess presenter?.destroy() would do?

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

3 participants