Changeset 186355 in webkit


Ignore:
Timestamp:
Jul 6, 2015 9:44:37 AM (9 years ago)
Author:
Antti Koivisto
Message:

With multipart/replaced (e.g. motion JPEG), m_bufferedDataForCache grows unbounded in Networking process
https://bugs.webkit.org/show_bug.cgi?id=146630
<rdar://problem/21677340>

Reviewed by Chris Dumez.

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::didReceiveResponseAsync):

Don't buffer multipart/x-mixed-replace. We never want to cache these.

(WebKit::NetworkResourceLoader::didReceiveBuffer):

Limit the maximum size of the cache buffer to 10MB. This prevents unbounded memory growth if the resource
keeps streaming. It also prevents giant entries from pushing other data out of the cache.

(WebKit::NetworkResourceLoader::didFinishLoading):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r186333 r186355  
     12015-07-06  Antti Koivisto  <antti@apple.com>
     2
     3        With multipart/replaced (e.g. motion JPEG), m_bufferedDataForCache grows unbounded in Networking process
     4        https://bugs.webkit.org/show_bug.cgi?id=146630
     5        <rdar://problem/21677340>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * NetworkProcess/NetworkResourceLoader.cpp:
     10        (WebKit::NetworkResourceLoader::didReceiveResponseAsync):
     11
     12            Don't buffer multipart/x-mixed-replace. We never want to cache these.
     13
     14        (WebKit::NetworkResourceLoader::didReceiveBuffer):
     15
     16            Limit the maximum size of the cache buffer to 10MB. This prevents unbounded memory growth if the resource
     17            keeps streaming. It also prevents giant entries from pushing other data out of the cache.
     18
     19        (WebKit::NetworkResourceLoader::didFinishLoading):
     20
    1212015-07-06  Zan Dobersek  <zdobersek@igalia.com>
    222
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp

    r183861 r186355  
    245245    bool shouldSendDidReceiveResponse = true;
    246246#if ENABLE(NETWORK_CACHE)
     247    if (m_response.isMultipart())
     248        m_bufferedDataForCache = nullptr;
     249
    247250    if (m_cacheEntryForValidation) {
    248251        bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified
     
    289292    ASSERT(!m_cacheEntryForValidation);
    290293
    291     if (m_bufferedDataForCache)
    292         m_bufferedDataForCache->append(buffer.get());
     294    if (m_bufferedDataForCache) {
     295        // Prevent memory growth in case of streaming data.
     296        const size_t maximumCacheBufferSize = 10 * 1014 * 1024;
     297        if (m_bufferedDataForCache->size() + buffer->size() <= maximumCacheBufferSize)
     298            m_bufferedDataForCache->append(buffer.get());
     299        else
     300            m_bufferedDataForCache = nullptr;
     301    }
    293302#endif
    294303    // FIXME: At least on OS X Yosemite we always get -1 from the resource handle.
     
    328337
    329338        bool isPrivate = sessionID().isEphemeral();
    330         if (hasCacheableRedirect && !isPrivate) {
     339        if (m_bufferedDataForCache && hasCacheableRedirect && !isPrivate) {
    331340            // Keep the connection alive.
    332341            RefPtr<NetworkConnectionToWebProcess> connection(connectionToWebProcess());
Note: See TracChangeset for help on using the changeset viewer.