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

question about router deactivation order #589

Open
davissuber opened this issue May 18, 2023 · 3 comments
Open

question about router deactivation order #589

davissuber opened this issue May 18, 2023 · 3 comments

Comments

@davissuber
Copy link
Contributor

davissuber commented May 18, 2023

This is a question regarding the reason why Routers first deactivate themselves before dispatching the deactivation to their children and perhaps a proposal to reverse that order.

For Android, the code is in this neighborhood, where dispatchDetach is called before detachChild (which will eventually call dispatchDetach on the child as well).

For iOS similar behavior can be observed here in the deinit block of Routers.

@psteiger
Copy link
Contributor

Did you encounter a specific use case where you would rather have your suggested behavior instead of the current behavior?

With that asked, in principle I agree with you: children must have a lifecycle less than or equal to the parent, so it makes sense for them to be deactivated before the parent.

@davissuber
Copy link
Contributor Author

davissuber commented May 18, 2023

When using RIBs with simple-store - it's quite reasonable to use the lifecycle provided by RIBs to manage simple-store (or any other resource that can only be opened once and needs to be closed when done).

In the current ordering where the children outlives the parent RIB, if one opens the simple-store in the parent RIB with the intention that both the parent RIB itself and the child RIB will make use of the store - there's a small window where the parent RIB will be deactivated (and the store cleaned up) while there are still activities coming from the children that make use of the store.

We are seeing some sporadic "the store is already closed" errors that could be caused by the current parent-child-deactivation-ordering - but still collecting evidence of such claim / find other causes and want to do some tentative finger-pointing in the process.

@davissuber
Copy link
Contributor Author

davissuber commented May 19, 2023

An update: we are able to repro the issue and it does seem that this ordering of children outliving the parent is creating problem for unsuspecting developers who binds an SimpleStore to the parent RIB's lifecycle, and use the store in the children lifecycle.

Perhaps the sharing of simple store across different scope provider per se is a bad way to use that library and one shouldn't make any strong assumption between parent and child scope deactivation order. 🤷

At any rate, given the potential impact of swapping the deactivation order at RIBs level - we are seeking alternative solutions to our problem at the moment, but it is our belief that the current behavior is creating some surprises in managing resources like simple store.

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