REGRESSION: ( r240978-r240985 ) [ iOS Release ] Layout Test imported/w3c/web-platform...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 19:54:21 +0000 (19:54 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 19:54:21 +0000 (19:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194523

Reviewed by Ryosuke Niwa.

Attempt to work around a CFNetwork bug in the timing of tearing down tasks with upload streams.
See rdar://problem/28233746.

* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:needNewBodyStream:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242367 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

index 06070b2..cbc09af 100644 (file)
@@ -1,3 +1,19 @@
+2019-03-04  Alex Christensen  <achristensen@webkit.org>
+
+        REGRESSION: ( r240978-r240985 ) [ iOS Release ] Layout Test imported/w3c/web-platform-tests/xhr/send-redirect-post-upload.htm is crashing
+        https://bugs.webkit.org/show_bug.cgi?id=194523
+
+        Reviewed by Ryosuke Niwa.
+
+        Attempt to work around a CFNetwork bug in the timing of tearing down tasks with upload streams.
+        See rdar://problem/28233746.
+
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:task:needNewBodyStream:]):
+
 2019-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [CoordinatedGraphics] The compositing loop is still running even after exiting AC mode
index 2ce677d..ee9fce5 100644 (file)
@@ -83,6 +83,8 @@ public:
 
     String description() const override;
 
+    void setShouldExtendTaskLifetime(bool shouldExtendTaskLifetime) { m_shouldExtendTaskLifetime = shouldExtendTaskLifetime; }
+
 private:
     NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, uint64_t frameID, uint64_t pageID, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation, Optional<NetworkActivityTracker>);
 
@@ -104,6 +106,9 @@ private:
     uint64_t m_frameID;
     uint64_t m_pageID;
 
+    // FIXME: This is only needed until rdar://problem/28233746 is fixed.
+    bool m_shouldExtendTaskLifetime { false };
+
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     bool m_hasBeenSetToUseStatelessCookieStorage { false };
 #endif
index 28c0c65..86770b8 100644 (file)
@@ -261,6 +261,9 @@ NetworkDataTaskCocoa::~NetworkDataTaskCocoa()
         ASSERT(cocoaSession.m_dataTaskMapWithoutState.get([m_task taskIdentifier]) == this);
         cocoaSession.m_dataTaskMapWithoutState.remove([m_task taskIdentifier]);
     }
+    
+    if (m_shouldExtendTaskLifetime)
+        RunLoop::main().dispatch([task = WTFMove(m_task)] { });
 }
 
 void NetworkDataTaskCocoa::restrictRequestReferrerToOriginIfNeeded(WebCore::ResourceRequest& request, bool shouldBlockCookies)
index 1907a55..76b62cc 100644 (file)
@@ -383,6 +383,7 @@ static String stringForSSLCipher(SSLCipherSuite cipher)
         return;
     }
 
+    networkDataTask->setShouldExtendTaskLifetime(true);
     completionHandler(WebCore::createHTTPBodyNSInputStream(*body).get());
 }