Skip to content

Navigation screens composed multiple times #1

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

Open
ewaldc opened this issue Apr 1, 2023 · 0 comments
Open

Navigation screens composed multiple times #1

ewaldc opened this issue Apr 1, 2023 · 0 comments

Comments

@ewaldc
Copy link

ewaldc commented Apr 1, 2023

First of all: thanks for this fine application architecture!

I have copied the architectural approach for my project (a Virtual Run App similar to Zwift) and everything runs fine, except for one thing: I noticed that when navigating to a different screen the start screen is recomposed even though it is not visible.
Since I'm an absolute newbie in Kotlin/Koin/Compose/Navigation (but experienced Linux kernel programmer), I checked to see if this issue also is present in the "master" code.

If I add 'Log.d' calls to 'AppNavigation.kt`, and start the app, then the logs show:

D/VRUN: AppNavigation: navigateToRepos - wycats
D/VRUN: AppNavigation: NavHost - Users
D/VRUN: AppNavigation: NavHost - Repos
D/VRUN: AppNavigation: NavHost - Repos
D/MIUIInput: [KeyEvent] ViewRootImpl KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0, eventTime=1659049858, downTime=1659049858, deviceId=-1, source=0x101, displayId=0 }
D/MIUIInput: [KeyEvent] ViewRootImpl KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0, eventTime=1659049952, downTime=1659049858, deviceId=-1, source=0x101, displayId=0 }
D/VRUN: AppNavigation: NavHost - Repos
D/VRUN: AppNavigation: NavHost - Users
D/VRUN: AppNavigation: NavHost - Users
D/VRUN: AppNavigation: navigateToRepos - ivey
D/VRUN: AppNavigation: NavHost - Users
D/VRUN: AppNavigation: NavHost - Repos
D/VRUN: AppNavigation: NavHost - Repos

So navigation to user wycats is invoking the USERS screen again before calling REPOS twice.
Also when going back, the sequence also seems strange: REPOS again and then USERS twice.
And of course, as the screen is recomposed, all composables down the tree are also recomposed.

This does not seem right...
Thanks in advance,
Ewald

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

1 participant