Wrap savestate and loadstate in thread to reduce the chance of UI deadlock