Skip to content

Empty SavedStateHandle for NavGraph Scoped ViewModel #2034

@getmidas-baris-basturk

Description

@getmidas-baris-basturk

Describe the bug
In Android, if system kills the application process or activity, previous state can be restored back when user returns to the application with the help of SavedStateHandle. SavedStateHandle is correctly injected by Koin in such cases for activityViewModel() etc. However, the injected SavedStateHandle is empty for navigation graph scoped view models. (e.g., koinNavGraphViewModel())

To Reproduce
Steps to reproduce the behavior:

  1. Enable Don't Keep Activities under Developer Options
  2. Run the sample app
  3. Click set state and then click go to second
  4. Press home, then return to app
  5. State should've been restored but lost

Expected behavior
When user returns back to app in the 5th step above, previous state should be restored from SavedStateHandle.

Koin module and version:
koin-core:3.5.6

Snippet or Sample project to help reproduce
KoinSavedStateHandleReproducer.zip

DKA_Disabled_Screen_recording_20241023_162612.mp4
DKA_Enabled_Screen_recording_20241023_162648.mp4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions