Changeset 169006 in webkit


Ignore:
Timestamp:
May 17, 2014 10:29:36 PM (10 years ago)
Author:
ap@apple.com
Message:

REGRESSION (NetworkProcess): Trying to use appcache fallback crashes in ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache
https://bugs.webkit.org/show_bug.cgi?id=133007
<rdar://problem/13702706>

appcache tests often fail on the Mac WebKit2 bot
https://bugs.webkit.org/show_bug.cgi?id=82061

Reviewed by Maciej Stachowiak.

Source/WebCore:
Covered by existing tests, which this patch enables.

  • WebCore.exp.in: Export ResourceLoader::cancel(const ResourceError&). It used

to be virtual, but marking subclasses final has resulted in the compiler calling
it directly from WebKitLegacy framework. Seeing that no subclass overrides it,
I then made it non-virtual.
Also export ApplicationCacheHost functions that are now used from WebKit2.

  • loader/ResourceLoader.h: Made the class abstract (as I didn't realize at first

that it's always either a SubresourceLoader or a NetscapePlugInStreamLoader).
Made ResourceHandleClient functions private, as they should never be called other
than via a ResourceHandleClient pointer.

  • loader/NetscapePlugInStreamLoader.h:
  • loader/SubresourceLoader.h:

Marked these final.

  • loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSwitchToSubstituteResource):

Added a function to be called when switching to a substitute resource. We still
need a ResourceLoader at this point, as substitute resource will be delivered through
it, but we don't want it to continue its current load.

  • loader/appcache/ApplicationCacheHost.cpp:

(WebCore::ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache):
Call the ResourceLoader function instead of using handle, which is null when
using out of process networking.

Source/WebKit2:

  • WebProcess/Network/WebResourceLoader.cpp:

(WebKit::WebResourceLoader::willSendRequest):
(WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo):
(WebKit::WebResourceLoader::didFailResourceLoad):
Perform the same appcache checks that ResourceHandleClient implementation in ResourceLoader
does. We should eventually come up with a way to share the code. Perhaps add a class that
isolates ResourceLoader from networking details? But ResourceLoader was itself supposed
to be the class that isolates DocumentLoader from networking details. So, unsure.

LayoutTests:

  • platform/mac-wk2/TestExpectations: Let's enable all the appcache tests (except

for a couple that fail), and see what happens on bots. I don't see any reason
why WebKit2 would be any more flaky than WebKit1 here.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r168996 r169006  
     12014-05-17  Alexey Proskuryakov  <ap@apple.com>
     2
     3        REGRESSION (NetworkProcess): Trying to use appcache fallback crashes in ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache
     4        https://bugs.webkit.org/show_bug.cgi?id=133007
     5        <rdar://problem/13702706>
     6
     7        appcache tests often fail on the Mac WebKit2 bot
     8        https://bugs.webkit.org/show_bug.cgi?id=82061
     9
     10        Reviewed by Maciej Stachowiak.
     11
     12        * platform/mac-wk2/TestExpectations: Let's enable all the appcache tests (except
     13        for a couple that fail), and see what happens on bots. I don't see any reason
     14        why WebKit2 would be any more flaky than WebKit1 here.
     15
    1162014-05-17  Piotr Grad  <p.grad@samsung.com>
    217
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r168577 r169006  
    178178fast/events/drag-link.html
    179179
    180 # appcache tests often fail on the Mac WebKit2 bot
    181 # https://bugs.webkit.org/show_bug.cgi?id=82061 rdar://problem/11108649
    182 http/tests/appcache
    183 
    184180# flaky storage tests
    185181# https://bugs.webkit.org/show_bug.cgi?id=82679
     
    356352webkit.org/b/132100 fast/forms/hidpi-textarea-on-subpixel-position.html [ ImageOnlyFailure ]
    357353
     354webkit.org/b/93980 http/tests/appcache/load-from-appcache-defer-resume-crash.html [ Skip ]
     355
    358356### END OF (1) Classified failures with bug reports
    359357########################################
     
    376374editing/spelling/spelling-insert-html.html
    377375editing/spelling/spelling-marker-description.html
     376
     377# This test times out, likely because appcache still loads in WebProcess, not NetworkProcess
     378http/tests/appcache/auth.html [ Skip ]
    378379
    379380### END OF (2) Classified failures without bug reports (yet)
  • trunk/Source/WebCore/ChangeLog

    r169004 r169006  
     12014-05-17  Alexey Proskuryakov  <ap@apple.com>
     2
     3        REGRESSION (NetworkProcess): Trying to use appcache fallback crashes in ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache
     4        https://bugs.webkit.org/show_bug.cgi?id=133007
     5        <rdar://problem/13702706>
     6
     7        appcache tests often fail on the Mac WebKit2 bot
     8        https://bugs.webkit.org/show_bug.cgi?id=82061
     9
     10        Reviewed by Maciej Stachowiak.
     11
     12        Covered by existing tests, which this patch enables.
     13
     14        * WebCore.exp.in: Export ResourceLoader::cancel(const ResourceError&). It used
     15        to be virtual, but marking subclasses final has resulted in the compiler calling
     16        it directly from WebKitLegacy framework. Seeing that no subclass overrides it,
     17        I then made it non-virtual.
     18        Also export ApplicationCacheHost functions that are now used from WebKit2.
     19
     20        * loader/ResourceLoader.h: Made the class abstract (as I didn't realize at first
     21        that it's always either a SubresourceLoader or a NetscapePlugInStreamLoader).
     22        Made ResourceHandleClient functions private, as they should never be called other
     23        than via a ResourceHandleClient pointer.
     24
     25        * loader/NetscapePlugInStreamLoader.h:
     26        * loader/SubresourceLoader.h:
     27        Marked these final.
     28
     29        * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSwitchToSubstituteResource):
     30        Added a function to be called when switching to a substitute resource. We still
     31        need a ResourceLoader at this point, as substitute resource will be delivered through
     32        it, but we don't want it to continue its current load.
     33
     34        * loader/appcache/ApplicationCacheHost.cpp:
     35        (WebCore::ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache):
     36        Call the ResourceLoader function instead of using handle, which is null when
     37        using out of process networking.
     38
    1392014-05-17  Andreas Kling  <akling@apple.com>
    240
  • trunk/Source/WebCore/WebCore.exp.in

    r168994 r169006  
    378378__ZN7WebCore14ResourceLoader14cancelledErrorEv
    379379__ZN7WebCore14ResourceLoader32didCancelAuthenticationChallengeERKNS_23AuthenticationChallengeE
     380__ZN7WebCore14ResourceLoader6cancelERKNS_13ResourceErrorE
    380381__ZN7WebCore14ResourceLoader6cancelEv
    381382__ZN7WebCore14SQLiteDatabase11tableExistsERKN3WTF6StringE
     
    825826__ZN7WebCore19toInt32EnforceRangeEPN3JSC9ExecStateENS0_7JSValueE
    826827__ZN7WebCore20ApplicationCacheHost17maybeLoadResourceEPNS_14ResourceLoaderERKNS_15ResourceRequestERKNS_3URLE
     828__ZN7WebCore20ApplicationCacheHost25maybeLoadFallbackForErrorEPNS_14ResourceLoaderERKNS_13ResourceErrorE
     829__ZN7WebCore20ApplicationCacheHost28maybeLoadFallbackForResponseEPNS_14ResourceLoaderERKNS_16ResourceResponseE
     830__ZN7WebCore20ApplicationCacheHost28maybeLoadFallbackForRedirectEPNS_14ResourceLoaderERNS_15ResourceRequestERKNS_16ResourceResponseE
    827831__ZN7WebCore20CachedResourceLoader31garbageCollectDocumentResourcesEv
    828832__ZN7WebCore20DictationAlternativeC1Ejjy
  • trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.h

    r165676 r169006  
    4949};
    5050
    51 class NetscapePlugInStreamLoader : public ResourceLoader {
     51class NetscapePlugInStreamLoader final : public ResourceLoader {
    5252public:
    5353    static PassRefPtr<NetscapePlugInStreamLoader> create(Frame*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r167635 r169006  
    208208}
    209209   
     210void ResourceLoader::willSwitchToSubstituteResource()
     211{
     212    ASSERT(!m_documentLoader->isSubstituteLoadPending(this));
     213    platformStrategies()->loaderStrategy()->resourceLoadScheduler()->remove(this);
     214    if (m_handle)
     215        m_handle->cancel();
     216}
    210217
    211218void ResourceLoader::addDataOrBuffer(const char* data, unsigned length, SharedBuffer* buffer, DataPayloadType dataPayloadType)
  • trunk/Source/WebCore/loader/ResourceLoader.h

    r167207 r169006  
    5656class ResourceLoader : public RefCounted<ResourceLoader>, protected ResourceHandleClient {
    5757public:
    58     virtual ~ResourceLoader();
     58    virtual ~ResourceLoader() = 0;
    5959
    6060    void cancel();
     
    7070
    7171    virtual const ResourceRequest& iOSOriginalRequest() const { return request(); }
    72     virtual RetainPtr<CFDictionaryRef> connectionProperties(ResourceHandle*) override;
    7372#endif
    7473
     
    7776    const ResourceRequest& originalRequest() const { return m_originalRequest; }
    7877   
    79     virtual void cancel(const ResourceError&);
     78    void cancel(const ResourceError&);
    8079    ResourceError cancelledError();
    8180    ResourceError blockedError();
     
    114113#endif
    115114    virtual void receivedCancellation(const AuthenticationChallenge&);
     115
     116    const URL& url() const { return m_request.url(); }
     117    ResourceHandle* handle() const { return m_handle.get(); }
     118    bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; }
     119    void setSendCallbackPolicy(SendCallbackPolicy sendLoadCallbacks) { m_options.sendLoadCallbacks = sendLoadCallbacks; }
     120    bool shouldSniffContent() const { return m_options.sniffContent == SniffContent; }
     121    ClientCredentialPolicy clientCredentialPolicy() const { return m_options.clientCredentialPolicy; }
     122
     123    bool reachedTerminalState() const { return m_reachedTerminalState; }
     124
     125    const ResourceRequest& request() const { return m_request; }
     126
     127    void setDataBufferingPolicy(DataBufferingPolicy);
     128
     129    void willSwitchToSubstituteResource();
     130
     131#if PLATFORM(MAC)
     132    void schedule(WTF::SchedulePair&);
     133    void unschedule(WTF::SchedulePair&);
     134#endif
     135
     136protected:
     137    ResourceLoader(Frame*, ResourceLoaderOptions);
     138
     139    friend class ResourceLoadScheduler; // for access to start()
     140    // start() actually sends the load to the network (unless the load is being
     141    // deferred) and should only be called by ResourceLoadScheduler or setDefersLoading().
     142    void start();
     143
     144    void didFinishLoadingOnePart(double finishTime);
     145    void cleanupForError(const ResourceError&);
     146
     147    bool wasCancelled() const { return m_cancellationStatus >= Cancelled; }
     148
     149    void didReceiveDataOrBuffer(const char*, unsigned, PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
     150
     151    const ResourceLoaderOptions& options() { return m_options; }
     152
     153    RefPtr<ResourceHandle> m_handle;
     154    RefPtr<Frame> m_frame;
     155    RefPtr<DocumentLoader> m_documentLoader;
     156    ResourceResponse m_response;
     157   
     158private:
     159    virtual void willCancel(const ResourceError&) = 0;
     160    virtual void didCancel(const ResourceError&) = 0;
     161
     162    void addDataOrBuffer(const char*, unsigned, SharedBuffer*, DataPayloadType);
    116163
    117164    // ResourceHandleClient
     
    125172    virtual void wasBlocked(ResourceHandle*) override;
    126173    virtual void cannotShowURL(ResourceHandle*) override;
     174#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
     175    virtual void didReceiveDataArray(ResourceHandle*, CFArrayRef dataArray) override;
     176#endif
    127177    virtual bool shouldUseCredentialStorage(ResourceHandle*) override { return shouldUseCredentialStorage(); }
    128178    virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) override { didReceiveAuthenticationChallenge(challenge); }
    129179    virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) override { didCancelAuthenticationChallenge(challenge); }
    130     virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) override { receivedCancellation(challenge); }
    131 
    132 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
    133     virtual void didReceiveDataArray(ResourceHandle*, CFArrayRef dataArray) override;
    134 #endif
    135 
    136180#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    137181    virtual bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace& protectionSpace) override { return canAuthenticateAgainstProtectionSpace(protectionSpace); }
    138182#endif
    139 
     183    virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) override { receivedCancellation(challenge); }
     184#if PLATFORM(COCOA) && !USE(CFNETWORK)
     185    virtual NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
     186#endif
    140187#if PLATFORM(COCOA) && USE(CFNETWORK)
    141188    virtual CFCachedURLResponseRef willCacheResponse(ResourceHandle*, CFCachedURLResponseRef) override;
    142189#endif
    143 
     190#if PLATFORM(IOS)
     191    virtual RetainPtr<CFDictionaryRef> connectionProperties(ResourceHandle*) override;
     192#endif
    144193#if PLATFORM(WIN) && USE(CFNETWORK)
    145194    // FIXME: Windows should use willCacheResponse - <https://bugs.webkit.org/show_bug.cgi?id=57257>.
    146195    virtual bool shouldCacheResponse(ResourceHandle*, CFCachedURLResponseRef) override;
    147196#endif
    148 
    149 #if PLATFORM(COCOA) && !USE(CFNETWORK)
    150     virtual NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
    151 #endif
    152 
    153197#if USE(QUICK_LOOK)
    154198    virtual void didCreateQuickLookHandle(QuickLookHandle&) override;
    155199#endif
    156 
    157     const URL& url() const { return m_request.url(); }
    158     ResourceHandle* handle() const { return m_handle.get(); }
    159     bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; }
    160     void setSendCallbackPolicy(SendCallbackPolicy sendLoadCallbacks) { m_options.sendLoadCallbacks = sendLoadCallbacks; }
    161     bool shouldSniffContent() const { return m_options.sniffContent == SniffContent; }
    162     ClientCredentialPolicy clientCredentialPolicy() const { return m_options.clientCredentialPolicy; }
    163 
    164     bool reachedTerminalState() const { return m_reachedTerminalState; }
    165 
    166     const ResourceRequest& request() const { return m_request; }
    167 
    168     void setDataBufferingPolicy(DataBufferingPolicy);
    169 
    170 #if PLATFORM(MAC)
    171     void schedule(WTF::SchedulePair&);
    172     void unschedule(WTF::SchedulePair&);
    173 #endif
    174 
    175 protected:
    176     ResourceLoader(Frame*, ResourceLoaderOptions);
    177 
    178     friend class ResourceLoadScheduler; // for access to start()
    179     // start() actually sends the load to the network (unless the load is being
    180     // deferred) and should only be called by ResourceLoadScheduler or setDefersLoading().
    181     void start();
    182 
    183     void didFinishLoadingOnePart(double finishTime);
    184     void cleanupForError(const ResourceError&);
    185 
    186     bool wasCancelled() const { return m_cancellationStatus >= Cancelled; }
    187 
    188     void didReceiveDataOrBuffer(const char*, unsigned, PassRefPtr<SharedBuffer>, long long encodedDataLength, DataPayloadType);
    189 
    190     const ResourceLoaderOptions& options() { return m_options; }
    191 
    192     RefPtr<ResourceHandle> m_handle;
    193     RefPtr<Frame> m_frame;
    194     RefPtr<DocumentLoader> m_documentLoader;
    195     ResourceResponse m_response;
    196    
    197 private:
    198     virtual void willCancel(const ResourceError&) = 0;
    199     virtual void didCancel(const ResourceError&) = 0;
    200 
    201     void addDataOrBuffer(const char*, unsigned, SharedBuffer*, DataPayloadType);
    202200
    203201    ResourceRequest m_request;
  • trunk/Source/WebCore/loader/SubresourceLoader.h

    r165676 r169006  
    4343class ResourceRequest;
    4444
    45 class SubresourceLoader : public ResourceLoader {
     45class SubresourceLoader final : public ResourceLoader {
    4646public:
    4747    static PassRefPtr<SubresourceLoader> create(Frame*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp

    r166847 r169006  
    400400        return false;
    401401
     402    loader->willSwitchToSubstituteResource();
     403
    402404    m_documentLoader->m_pendingSubstituteResources.set(loader, resource);
    403405    m_documentLoader->deliverSubstituteResourcesAfterDelay();
    404    
    405     loader->handle()->cancel();
    406406
    407407    return true;
  • trunk/Source/WebKit2/ChangeLog

    r169003 r169006  
     12014-05-17  Alexey Proskuryakov  <ap@apple.com>
     2
     3        REGRESSION (NetworkProcess): Trying to use appcache fallback crashes in ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache
     4        https://bugs.webkit.org/show_bug.cgi?id=133007
     5        <rdar://problem/13702706>
     6
     7        appcache tests often fail on the Mac WebKit2 bot
     8        https://bugs.webkit.org/show_bug.cgi?id=82061
     9
     10        Reviewed by Maciej Stachowiak.
     11
     12        * WebProcess/Network/WebResourceLoader.cpp:
     13        (WebKit::WebResourceLoader::willSendRequest):
     14        (WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo):
     15        (WebKit::WebResourceLoader::didFailResourceLoad):
     16        Perform the same appcache checks that ResourceHandleClient implementation in ResourceLoader
     17        does. We should eventually come up with a way to share the code. Perhaps add a class that
     18        isolates ResourceLoader from networking details? But ResourceLoader was itself supposed
     19        to be the class that isolates DocumentLoader from networking details. So, unsure.
     20
    1212014-05-17  Jae Hyun Park  <jaepark@webkit.org>
    222
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp

    r167894 r169006  
    3636#include "WebErrors.h"
    3737#include "WebProcess.h"
     38#include <WebCore/ApplicationCacheHost.h>
    3839#include <WebCore/CertificateInfo.h>
    3940#include <WebCore/DocumentLoader.h>
     
    8586
    8687    Ref<WebResourceLoader> protect(*this);
    87    
     88
    8889    ResourceRequest newRequest = proposedRequest;
     90    if (m_coreLoader->documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(m_coreLoader.get(), newRequest, redirectResponse))
     91        return;
    8992    m_coreLoader->willSendRequest(newRequest, redirectResponse);
    9093   
     
    121124    responseCopy.setSoupMessageTLSErrors(certificateInfo.tlsErrors());
    122125#endif
     126    if (m_coreLoader->documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(m_coreLoader.get(), responseCopy))
     127        return;
    123128    m_coreLoader->didReceiveResponse(responseCopy);
    124129
     
    164169        m_quickLookHandle->didFail();
    165170#endif
     171    if (m_coreLoader->documentLoader()->applicationCacheHost()->maybeLoadFallbackForError(m_coreLoader.get(), error))
     172        return;
    166173    m_coreLoader->didFail(error);
    167174}
Note: See TracChangeset for help on using the changeset viewer.