-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] document.title

, 03 2017 . 13:00 +
, , document.title , , (.. , /, , , , , ). , , 56, Chrome . ?

, rAF (requestAnimationFrame) 60 . , , ( ).

, , , , , .

. requestAnimationFrame :

requestAnimationFrame




  
  


tab




:

Chrome


, . , :

IE11

Safari


Firefox

, e10s Electrolysis

Firefox rAF . , IE11 rAF , , Per the documentation, Chrome does not call requestAnimationFrame() when a page is in the background. This behavior has been in place since 2011. 2011, !, , . , ( ), rAF, , , , FF, .

, , , API. , API ( )), -. , , - , . , setTimeout/setInterval, , .

, , , requestAnimationFrame WebKit:

int Document::requestAnimationFrame(Ref&& callback)
{
    if (!m_scriptedAnimationController) {
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
        m_scriptedAnimationController = ScriptedAnimationController::create(*this, page() ? page()->chrome().displayID() : 0);
#else
        m_scriptedAnimationController = ScriptedAnimationController::create(*this, 0);
#endif
        // It's possible that the Page may have suspended scripted animations before
        // we were created. We need to make sure that we don't start up the animation
        // controller on a background tab, for example.
        if (!page() || page()->scriptedAnimationsSuspended())
            m_scriptedAnimationController->suspend();

        if (page() && page()->isLowPowerModeEnabled())
            m_scriptedAnimationController->addThrottlingReason(ScriptedAnimationController::ThrottlingReason::LowPowerMode);

        if (!topOrigin().canAccess(securityOrigin()) && !hasHadUserInteraction())
            m_scriptedAnimationController->addThrottlingReason(ScriptedAnimationController::ThrottlingReason::NonInteractedCrossOriginFrame);
    }

    return m_scriptedAnimationController->registerCallback(WTFMove(callback));
}

if , suspendScriptedAnimations setIsVisibleInternal.

if, isLowPowerModeEnabled, ; iOS, , _didReceiveLowPowerModeChange.

if ; topOrigin SecurityOrigin ; , , . true, origin ( ). , NonInteractedCrossOriginFrame.

, webkit- rAF , if.

Firefox. , , :

animationFrame
    requestAnimationFrame(function handler() {
      document.title += 'R'
      requestAnimationFrame(handler);
    });




, Firefox/Gecko , webkit. request_animation_frame, , :

  1. // TODO: Should tick animation only when document is visible , - , , , .
  2. is_faking_animation_frames , Gecko, , , FakeRequestAnimationFrameCallback.

, .

:

Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/332174/

:  

: [1] []
 

:
: 

: ( )

:

  URL