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

Node does is missing onDestroy callback in some cases #293

Closed
KovalevAndrey opened this issue Dec 2, 2022 · 3 comments
Closed

Node does is missing onDestroy callback in some cases #293

KovalevAndrey opened this issue Dec 2, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@KovalevAndrey
Copy link
Collaborator

More info here

Similarly, can be reproduced following these steps:

  1. Open sample sandbox
  2. Click explicit navigation button
  3. Click Push two
  4. In Grandchild one click Navigate to child one
  5. Observe lifecycle events in the logs. On destroy is not received
@KovalevAndrey KovalevAndrey added the bug Something isn't working label Dec 2, 2022
@KovalevAndrey KovalevAndrey self-assigned this Dec 2, 2022
@dimsuz
Copy link

dimsuz commented Dec 2, 2022

This kept happening for me on 1x snapshot and so while trying to come up with the minimal example, I have found that I've actually misguided you :(

I wasn't using backStack.newRoot(), but rather I was using backStack.singleTop().
But still, this singleTop call should result in a completely new hierarchy where even the root node is different from the previously active one, and so I believe it still should call onDestroy on inactive ones?

Here I've build a one-file sample which you can insert in some project, then make that activity a default one and run the app.

Steps to reproduce:

  1. Click on buttons until you arrive to the "main screen"
  2. Observe the following in logs:
[Login] node onCreate
[Login] node onStart
[Permissions] node onCreate
[Permissions] node onStart
[Main] node onCreate
[Main] node onStart
[Login] node onStop
[Permissions] node onStop

As you can see in the end, onDestroy is not called after singleTop() → only onStop
If you switch singleTop to newRoot, then onDestroy is called.

@KovalevAndrey
Copy link
Collaborator Author

@dimsuz I've just checked out your example and it look like you're using singleTop(Main) while backStack has active Login navTarget. It results in LoginNode subtree moving into STASHED, not DESTOYED state which is correct.

Please check out singleTop documentation to see the expected behaviour

@dimsuz
Copy link

dimsuz commented Dec 5, 2022

Oh! 🤦 Indeed, I don't know why I expected singleTop to work like newRoot. So everything works as it should!

I guess this issue can be safely closed then. Thanks for all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants