patched getScreenshot for ios to avoid race condition