Frame state restore assumption

Nov 2, 2013 at 12:08 AM
When frame state is restored the code look's out for a specific exception, which is possible. If this occurs the comments indicate 'assume no state' and a clean start. The code comments do say 'assume'. I read it as assuming the state of a clean start with no state, but it could reasonably mean assume there is no state restored because there was an exception so catch and continue, which may be less than ideal.

Which way round is it? If the latter, should there be an explicit clearing of all frame state when this exception is thrown perhaps.

I apologise in advance if this has been covered in the new version or I've not spotted a discussion on tis topic. (At present I am working with the current release and not had chance to look closely at the new version being worked on)

Many thanks.
Nov 4, 2013 at 5:15 PM
Hi thebwalker,

Based on my understanding, the answer would be the second one.
When trying to restore the NavigationState, a SessionStateService exception could be thrown which would then be catched and ignored, by making the restored session run without the navigation history.
This scenario may occur after the session was successfully restored as it can be seen on the RestoreSessionStateAsync() call 6 lines above in the implementation which the exception doesn´t get catched.

If you would want to explicitly clear every frame state which are referenced from the registeredFrames list, you could call frame.ClearValue(FrameSessionStateProperty); method after retreiving the target of each weak frame reference.


I hope this helps,
Gabriel Ostrowsky
https://blogs.southworks.net/gostrowsky