Zhuinden / simple-stack

[ACTIVE] Simple Stack, a backstack library / navigation framework for simpler navigation and state management (for fragments, views, or whatevers).
Apache License 2.0
1.36k stars 76 forks source link

ScopeManager.lookupService() ignores built scopes that are not in the latest state during navigation #198

Closed Zhuinden closed 4 years ago

Zhuinden commented 4 years ago

Since 1.13.0 where explicit parents were introduced, the lookupService method relies on List<Object> latestState = this.latestState; to reconstruct the scope hierarchy for proper ordering.

However, this actually skips uncleared scopes that are intermittent during navigation.

This can result in an error of not finding services inside views inflated by ViewPagers as the view inflation of these child views is delayed, and doesn't occur immediately when added to the view hierarchy. By the time they are inflated, the "latest state" belongs to the current navigation target -- and while the scope actually exists, the lookup does not find it.

A test case to reproduce this must be added, along with a fallback mechanism -- and it's quite crucial to fix this ASAP.