Navigation component crash on rotate

There is a problem with nav controller backstack after changed config

In your Activity with fragment: try saving the nav controller state before changing the configuration. After changing the configuration, add it back to the nav controller again. Like:

override fun onSaveInstanceState(savedInstanceState: Bundle) {
    super.onSaveInstanceState(savedInstanceState)
    savedInstanceState.putBundle("nav_state", fragment.findNavController().saveState())
}
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
    super.onRestoreInstanceState(savedInstanceState)
    fragment.findNavController().restoreState(savedInstanceState.getBundle("nav_state"))
}

That was my case