Fix for swapBuffers crash and animations issue

Fixes an issue with a crash that happens if the app is backgrounded while a view controller is appearing.