Closed topnax closed 4 years ago
Might be fixed by #234
I can confirm that disabling fragment transactions animations fixes this issue.
Hrmm, I'm not sure why the fragment animation makes that happen (fragment animations always live their own life to some degree ☹️) , but as outlined in https://github.com/Zhuinden/simple-stack/issues/234#issuecomment-674445940 the animations are customizable (through override
).
The reason why fragmentTransaction.commitAllowingStateLoss()
is used, is because fragmentTransaction.commitNow*()
gets "confused" when DialogFragments are involved. But as fragmentTransaction.commitAllowingStateLoss()
is used, supportFragmentManager.executePendingTransactions()
is used if there would be overlapping fragment transactions. 🤔
So anything that is not commitAllowingStateLoss()
in this pattern hasn't been as stable, which is why DefaultFragmentStateChanger
doesn't expose a way to change it at the moment. The delayed execution of FragmentTransactions can be overridden through via supportFragmentManager.executePendingTransactions()
if truly needed. 🤔
I truly do wonder where the slowness comes from. I haven't experienced anything of the sort, and it's been a while... I might need a sample but fragments do have their own way of doing things.
Theoretically, animations shouldn't slow down the views, but it's true that due to the default behavior of attach
/detach
, it can be slow (just like replace.addToBackStack
, as this is the only way to reliably trigger the right lifecycle events in Fragments atm).
commitAllowingStateLoss()
is used as it is the only way to safely trigger fragment transactions when DialogFragments are involved, commitNow()
breaks that.
Unfortunately, with this amount of info, all I can say is "I recommend checking for the inflation time with a profiler, and if that is the culprit, maybe consider using show/hide like https://github.com/Zhuinden/simple-stack/issues/235#issuecomment-679924722"
Imagine this scenario:
onResume()
)Expected behaviour:
Reality:
Using just fragment transactions, the login screen is not visible while being moved to the foreground (
commitNow()
is used). Any ideas how to improve this? I guess this can be fixed in theDefaultFragmentStateChanger
class.Thank you very much for the rest of the amazing library