Request animation frame stops working when exiting fullscreen by clicking on original space's safari window. Everything is fine if fullscreen mode is canceled with escape key or calling cancelFullScreen().
Steps to reproduce:
What it does is just handling the click calling:
window.requestAnimationFrame(draw);
which just draws something on a canvas context:
function draw() {
ctx.drawImage(img, Math.random()*500|0, Math.random()*400|0, 100, 100);
}
I also checked the .hidden and .visibilityState, they get updated correctly.
Tested on osx 10.9.3, safari 7.0.4 (9537.76.4).
Has anyone any workaround/solution for this other than switching to the good old setTimeout?
This sounds like WebKit Bug 88940:
Using requestAnimationFrame and the fullscreen API on a DrawingArea-backed window would cause rAF to permanently suspend animations when fullscreened, because of the following:
- JavaScript causes fullscreen transition to start.
- Painting (and rAF) are suspended.
- The page changes size. a. DrawingAreaProxyImpl::sizeDidChange() calls DrawingAreaImpl::updateBackingStoreState, which calls DrawingAreaImpl::resumePainting. b. DrawingAreaImpl::resumePainting resumes painting, but does not resume rAF, because windowIsVisible is (legitimately) false.
- The view becomes visible, windowIsVisible is updated to true.
- visibilityDidChange() calls resumePainting again, but this time it early exits because painting is not suspended.
Notice that because of the early exit in 4, rAF is never resumed.
Based on this description I suspect there is no effective workaround, since the drawing area gets into a state where calling resumePainting has no effect.
(Thanks to Jason Davies for finding this bug report.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With