⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176297 in webkit


Ignore:
Timestamp:
Nov 18, 2014, 4:56:33 PM (12 years ago)
Author:
Chris Dumez
Message:

Add a setting to toggle DOMTimer throttling support
https://bugs.webkit.org/show_bug.cgi?id=138844
<rdar://problem/19020874>

Reviewed by Andreas Kling.

Add a setting to disable DOM timers throttling, in order to help
developers determine if a specific issue is caused by timer
throttling.

Source/WebCore:

  • page/DOMTimer.cpp:

(WebCore::DOMTimerFireState::contextDocument):
(WebCore::DOMTimerFireState::scriptMadeUserObservableChanges):
(WebCore::DOMTimer::isDOMTimersThrottlingEnabled):
(WebCore::DOMTimer::updateThrottlingStateIfNecessary):

  • page/DOMTimer.h:
  • page/Settings.in:

Source/WebKit/mac:

  • WebView/WebPreferenceKeysPrivate.h:
  • WebView/WebPreferences.mm:

(+[WebPreferences initialize]):
(-[WebPreferences domTimersThrottlingEnabled]):
(-[WebPreferences setDOMTimersThrottlingEnabled:]):

  • WebView/WebPreferencesPrivate.h:
  • WebView/WebView.mm:

(-[WebView _preferencesChanged:]):

Source/WebKit2:

  • Shared/WebPreferencesDefinitions.h:
  • UIProcess/API/C/WKPreferences.cpp:

(WKPreferencesSetDOMTimersThrottlingEnabled):
(WKPreferencesGetDOMTimersThrottlingEnabled):

  • UIProcess/API/C/WKPreferencesRefPrivate.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::updatePreferences):

Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176296 r176297  
     12014-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Add a setting to toggle DOMTimer throttling support
     4        https://bugs.webkit.org/show_bug.cgi?id=138844
     5        <rdar://problem/19020874>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Add a setting to disable DOM timers throttling, in order to help
     10        developers determine if a specific issue is caused by timer
     11        throttling.
     12
     13        * page/DOMTimer.cpp:
     14        (WebCore::DOMTimerFireState::contextDocument):
     15        (WebCore::DOMTimerFireState::scriptMadeUserObservableChanges):
     16        (WebCore::DOMTimer::isDOMTimersThrottlingEnabled):
     17        (WebCore::DOMTimer::updateThrottlingStateIfNecessary):
     18        * page/DOMTimer.h:
     19        * page/Settings.in:
     20
    1212014-11-18  Beth Dakin  <bdakin@apple.com>
    222
  • trunk/Source/WebCore/page/DOMTimer.cpp

    r176282 r176297  
    3232#include "InspectorInstrumentation.h"
    3333#include "Logging.h"
     34#include "Page.h"
    3435#include "PluginViewBase.h"
    3536#include "ScheduledAction.h"
    3637#include "ScriptExecutionContext.h"
     38#include "Settings.h"
    3739#include "UserGestureIndicator.h"
    3840#include <wtf/CurrentTime.h>
     
    4648#include "ChromeClient.h"
    4749#include "Frame.h"
    48 #include "Page.h"
    4950#include "WKContentObservation.h"
    5051#endif
     
    7879    }
    7980
     81    Document* contextDocument() const { return m_contextIsDocument ? &downcast<Document>(m_context) : nullptr; }
     82
    8083    void setScriptMadeUserObservableChanges() { m_scriptMadeUserObservableChanges = true; }
    8184    void setScriptMadeNonUserObservableChanges() { m_scriptMadeNonUserObservableChanges = true; }
     
    9295            return true;
    9396
     97        Document* document = contextDocument();
    9498        // To be conservative, we also consider any DOM Tree change to be user observable.
    95         return m_contextIsDocument && downcast<Document>(m_context).domTreeVersion() != m_initialDOMTreeVersion;
     99        return document && document->domTreeVersion() != m_initialDOMTreeVersion;
    96100    }
    97101
     
    252256}
    253257
     258inline bool DOMTimer::isDOMTimersThrottlingEnabled(Document& document) const
     259{
     260    auto* page = document.page();
     261    if (!page)
     262        return true;
     263    return page->settings().domTimersThrottlingEnabled();
     264}
     265
    254266void DOMTimer::updateThrottlingStateIfNecessary(const DOMTimerFireState& fireState)
    255267{
     268    Document* contextDocument = fireState.contextDocument();
     269    // We don't throttle timers in worker threads.
     270    if (!contextDocument)
     271        return;
     272
     273    if (UNLIKELY(!isDOMTimersThrottlingEnabled(*contextDocument))) {
     274        if (m_throttleState == ShouldThrottle) {
     275            // Unthrottle the timer in case it was throttled before the setting was updated.
     276            LOG(DOMTimers, "%p - Unthrottling DOM timer because throttling was disabled via settings.", this);
     277            m_throttleState = ShouldNotThrottle;
     278            updateTimerIntervalIfNecessary();
     279        }
     280        return;
     281    }
     282
    256283    if (fireState.scriptMadeUserObservableChanges()) {
    257284        ASSERT(m_elementsCausingThrottling.isEmpty());
  • trunk/Source/WebCore/page/DOMTimer.h

    r176239 r176297  
    3636
    3737    class DOMTimerFireState;
     38    class Document;
    3839    class HTMLPlugInElement;
    3940    class IntRect;
     
    6667        double intervalClampedToMinimum() const;
    6768
     69        bool isDOMTimersThrottlingEnabled(Document&) const;
    6870        bool isIntervalDependentOnViewport() const { return m_throttleState == ShouldThrottle && !m_elementsCausingThrottling.isEmpty(); }
    6971        void registerForViewportChanges();
  • trunk/Source/WebCore/page/Settings.in

    r176199 r176297  
    7777scriptMarkupEnabled initial=true
    7878needsSiteSpecificQuirks initial=false
     79domTimersThrottlingEnabled initial=true
    7980webArchiveDebugModeEnabled initial=false, conditional=WEB_ARCHIVE
    8081localFileContentSniffingEnabled initial=false
  • trunk/Source/WebKit/mac/ChangeLog

    r176288 r176297  
     12014-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Add a setting to toggle DOMTimer throttling support
     4        https://bugs.webkit.org/show_bug.cgi?id=138844
     5        <rdar://problem/19020874>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Add a setting to disable DOM timers throttling, in order to help
     10        developers determine if a specific issue is caused by timer
     11        throttling.
     12
     13        * WebView/WebPreferenceKeysPrivate.h:
     14        * WebView/WebPreferences.mm:
     15        (+[WebPreferences initialize]):
     16        (-[WebPreferences domTimersThrottlingEnabled]):
     17        (-[WebPreferences setDOMTimersThrottlingEnabled:]):
     18        * WebView/WebPreferencesPrivate.h:
     19        * WebView/WebView.mm:
     20        (-[WebView _preferencesChanged:]):
     21
    1222014-11-18  Tim Horton  <timothy_horton@apple.com>
    223
  • trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h

    r176199 r176297  
    8888#define WebKitAuthorAndUserStylesEnabledPreferenceKey @"WebKitAuthorAndUserStylesEnabledPreferenceKey"
    8989#define WebKitApplicationChromeModeEnabledPreferenceKey @"WebKitApplicationChromeModeEnabledPreferenceKey"
     90#define WebKitDOMTimersThrottlingEnabledPreferenceKey @"WebKitDOMTimersThrottlingEnabledPreferenceKey"
    9091#define WebKitWebArchiveDebugModeEnabledPreferenceKey @"WebKitWebArchiveDebugModeEnabledPreferenceKey"
    9192#define WebKitLocalFileContentSniffingEnabledPreferenceKey @"WebKitLocalFileContentSniffingEnabledPreferenceKey"
  • trunk/Source/WebKit/mac/WebView/WebPreferences.mm

    r176199 r176297  
    477477        [NSNumber numberWithBool:YES],  WebKitAuthorAndUserStylesEnabledPreferenceKey,
    478478        [NSNumber numberWithBool:NO],   WebKitApplicationChromeModeEnabledPreferenceKey,
     479        [NSNumber numberWithBool:YES],  WebKitDOMTimersThrottlingEnabledPreferenceKey,
    479480        [NSNumber numberWithBool:NO],   WebKitWebArchiveDebugModeEnabledPreferenceKey,
    480481        [NSNumber numberWithBool:NO],   WebKitLocalFileContentSniffingEnabledPreferenceKey,
     
    12231224{
    12241225    [self _setBoolValue:flag forKey:WebKitApplicationChromeModeEnabledPreferenceKey];
     1226}
     1227
     1228- (BOOL)domTimersThrottlingEnabled
     1229{
     1230    return [self _boolValueForKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
     1231}
     1232
     1233- (void)setDOMTimersThrottlingEnabled:(BOOL)flag
     1234{
     1235    [self _setBoolValue:flag forKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
    12251236}
    12261237
  • trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h

    r176199 r176297  
    103103- (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel;
    104104
     105- (BOOL)domTimersThrottlingEnabled;
     106- (void)setDOMTimersThrottlingEnabled:(BOOL)domTimersThrottlingEnabled;
     107
    105108- (BOOL)webArchiveDebugModeEnabled;
    106109- (void)setWebArchiveDebugModeEnabled:(BOOL)webArchiveDebugModeEnabled;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r176265 r176297  
    22232223
    22242224    settings.setNeedsSiteSpecificQuirks(_private->useSiteSpecificSpoofing);
     2225    settings.setDOMTimersThrottlingEnabled([preferences domTimersThrottlingEnabled]);
    22252226    settings.setWebArchiveDebugModeEnabled([preferences webArchiveDebugModeEnabled]);
    22262227    settings.setLocalFileContentSniffingEnabled([preferences localFileContentSniffingEnabled]);
  • trunk/Source/WebKit2/ChangeLog

    r176290 r176297  
     12014-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Add a setting to toggle DOMTimer throttling support
     4        https://bugs.webkit.org/show_bug.cgi?id=138844
     5        <rdar://problem/19020874>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Add a setting to disable DOM timers throttling, in order to help
     10        developers determine if a specific issue is caused by timer
     11        throttling.
     12
     13        * Shared/WebPreferencesDefinitions.h:
     14        * UIProcess/API/C/WKPreferences.cpp:
     15        (WKPreferencesSetDOMTimersThrottlingEnabled):
     16        (WKPreferencesGetDOMTimersThrottlingEnabled):
     17        * UIProcess/API/C/WKPreferencesRefPrivate.h:
     18        * WebProcess/WebPage/WebPage.cpp:
     19        (WebKit::WebPage::updatePreferences):
     20
    1212014-11-18  Geoffrey Garen  <ggaren@apple.com>
    222
  • trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h

    r176199 r176297  
    121121    macro(TabsToLinks, tabsToLinks, Bool, bool, DEFAULT_WEBKIT_TABSTOLINKS_ENABLED) \
    122122    macro(DNSPrefetchingEnabled, dnsPrefetchingEnabled, Bool, bool, false) \
     123    macro(DOMTimersThrottlingEnabled, domTimersThrottlingEnabled, Bool, bool, true) \
    123124    macro(WebArchiveDebugModeEnabled, webArchiveDebugModeEnabled, Bool, bool, false) \
    124125    macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false) \
  • trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp

    r176199 r176297  
    580580}
    581581
     582void WKPreferencesSetDOMTimersThrottlingEnabled(WKPreferencesRef preferencesRef, bool enabled)
     583{
     584    toImpl(preferencesRef)->setDOMTimersThrottlingEnabled(enabled);
     585}
     586
     587bool WKPreferencesGetDOMTimersThrottlingEnabled(WKPreferencesRef preferencesRef)
     588{
     589    return toImpl(preferencesRef)->domTimersThrottlingEnabled();
     590}
     591
    582592void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef, bool enabled)
    583593{
  • trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h

    r176199 r176297  
    117117WK_EXPORT WKStringRef WKPreferencesCopyFTPDirectoryTemplatePath(WKPreferencesRef preferences);
    118118
     119// Defaults to true.
     120WK_EXPORT void WKPreferencesSetDOMTimersThrottlingEnabled(WKPreferencesRef preferences, bool enabled);
     121WK_EXPORT bool WKPreferencesGetDOMTimersThrottlingEnabled(WKPreferencesRef preferences);
     122
    119123// Defaults to false.
    120124WK_EXPORT void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferences, bool enabled);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r176229 r176297  
    26612661    settings.setForceFTPDirectoryListings(store.getBoolValueForKey(WebPreferencesKey::forceFTPDirectoryListingsKey()));
    26622662    settings.setDNSPrefetchingEnabled(store.getBoolValueForKey(WebPreferencesKey::dnsPrefetchingEnabledKey()));
     2663    settings.setDOMTimersThrottlingEnabled(store.getBoolValueForKey(WebPreferencesKey::domTimersThrottlingEnabledKey()));
    26632664#if ENABLE(WEB_ARCHIVE)
    26642665    settings.setWebArchiveDebugModeEnabled(store.getBoolValueForKey(WebPreferencesKey::webArchiveDebugModeEnabledKey()));
Note: See TracChangeset for help on using the changeset viewer.