fixed crash when app resumes from a long sleep