Changeset 80307 in webkit


Ignore:
Timestamp:
Mar 3, 2011 5:37:11 PM (13 years ago)
Author:
Adam Roben
Message:

Throw away DrawingAreaProxyImpl's backing store after not painting for 5 seconds

The intent is to save memory for views that aren't painting.

Fixes <http://webkit.org/b/51262> <rdar://problem/8782537> WebPageProxy should delete its
backing store after not painting for a while

Reviewed by Anders Carlsson.

  • UIProcess/DrawingAreaProxyImpl.cpp:

(WebKit::DrawingAreaProxyImpl::DrawingAreaProxyImpl): Initialize our timer.
(WebKit::DrawingAreaProxyImpl::paint): Don't bail if we don't have a backing store (but do
bail if we're in accelerated compositing mode); we might have thrown it away to save memory
but now are being asked to paint by the view. The existing code in this function will handle
getting a new backing store if possible by blocking for a little while to try to receive a
DidUpdateBackingStoreState message. Added an assertion that we do have a backing store if we
don't have any outstanding UpdateBackingStoreState requests. After painting, call
discardBackingStoreSoon to update our timer.
(WebKit::DrawingAreaProxyImpl::discardBackingStoreSoon): Set the timer for 5 seconds in the
future.
(WebKit::DrawingAreaProxyImpl::discardBackingStore): Throw away the backing store, and tell
the web process we'll need a full backing store update on the next paint.

  • UIProcess/DrawingAreaProxyImpl.h: Added m_discardBackingStoreTimer.
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r80306 r80307  
     12011-03-03  Adam Roben  <aroben@apple.com>
     2
     3        Throw away DrawingAreaProxyImpl's backing store after not painting for 5 seconds
     4
     5        The intent is to save memory for views that aren't painting.
     6
     7        Fixes <http://webkit.org/b/51262> <rdar://problem/8782537> WebPageProxy should delete its
     8        backing store after not painting for a while
     9
     10        Reviewed by Anders Carlsson.
     11
     12        * UIProcess/DrawingAreaProxyImpl.cpp:
     13        (WebKit::DrawingAreaProxyImpl::DrawingAreaProxyImpl): Initialize our timer.
     14        (WebKit::DrawingAreaProxyImpl::paint): Don't bail if we don't have a backing store (but do
     15        bail if we're in accelerated compositing mode); we might have thrown it away to save memory
     16        but now are being asked to paint by the view. The existing code in this function will handle
     17        getting a new backing store if possible by blocking for a little while to try to receive a
     18        DidUpdateBackingStoreState message. Added an assertion that we do have a backing store if we
     19        don't have any outstanding UpdateBackingStoreState requests. After painting, call
     20        discardBackingStoreSoon to update our timer.
     21        (WebKit::DrawingAreaProxyImpl::discardBackingStoreSoon): Set the timer for 5 seconds in the
     22        future.
     23        (WebKit::DrawingAreaProxyImpl::discardBackingStore): Throw away the backing store, and tell
     24        the web process we'll need a full backing store update on the next paint.
     25
     26        * UIProcess/DrawingAreaProxyImpl.h: Added m_discardBackingStoreTimer.
     27
    1282011-03-03  Adam Roben  <aroben@apple.com>
    229
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp

    r80306 r80307  
    5353    , m_nextBackingStoreStateID(0)
    5454    , m_isWaitingForDidUpdateBackingStoreState(false)
     55    , m_discardBackingStoreTimer(RunLoop::current(), this, &DrawingAreaProxyImpl::discardBackingStore)
    5556{
    5657}
     
    6768    unpaintedRegion = rect;
    6869
    69     if (!m_backingStore)
    70         return;
    71 
    72     ASSERT(!isInAcceleratedCompositingMode());
     70    if (isInAcceleratedCompositingMode())
     71        return;
    7372
    7473    ASSERT(m_currentBackingStoreStateID <= m_nextBackingStoreStateID);
     
    8988        if (!m_backingStore || isInAcceleratedCompositingMode())
    9089            return;
    91     } else
     90    } else {
    9291        ASSERT(!m_isWaitingForDidUpdateBackingStoreState);
     92        ASSERT(m_backingStore);
     93    }
    9394
    9495    m_backingStore->paint(context, rect);
    9596    unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size()));
     97
     98    discardBackingStoreSoon();
    9699}
    97100
     
    289292}
    290293
     294void DrawingAreaProxyImpl::discardBackingStoreSoon()
     295{
     296    // We'll wait this many seconds after the last paint before throwing away our backing store to save memory.
     297    // FIXME: It would be smarter to make this delay based on how expensive painting is. See <http://webkit.org/b/55733>.
     298    static const double discardBackingStoreDelay = 5;
     299
     300    m_discardBackingStoreTimer.startOneShot(discardBackingStoreDelay);
     301}
     302
     303void DrawingAreaProxyImpl::discardBackingStore()
     304{
     305    m_backingStore = nullptr;
     306    backingStoreStateDidChange(DoNotRespondImmediately);
     307}
     308
    291309} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h

    r80306 r80307  
    3030#include "DrawingAreaProxy.h"
    3131#include "LayerTreeContext.h"
     32#include "RunLoop.h"
    3233#include <wtf/OwnPtr.h>
    3334#include <wtf/PassOwnPtr.h>
     
    7374    bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
    7475
     76    void discardBackingStoreSoon();
     77    void discardBackingStore();
     78
    7579    // The state ID corresponding to our current backing store. Updated whenever we allocate
    7680    // a new backing store. Any messages received that correspond to an earlier state are ignored,
     
    9094
    9195    OwnPtr<BackingStore> m_backingStore;
     96
     97    RunLoop::Timer<DrawingAreaProxyImpl> m_discardBackingStoreTimer;
    9298};
    9399
Note: See TracChangeset for help on using the changeset viewer.