Fix a crash when leaving then entering foreground on iOS.