Title: [261762] trunk
Revision
261762
Author
[email protected]
Date
2020-05-15 14:32:37 -0700 (Fri, 15 May 2020)

Log Message

[iOS Simulator] TestWebKitAPI._WKDownload.Resume is a flaky crash
https://bugs.webkit.org/show_bug.cgi?id=211786

Patch by Alex Christensen <[email protected]> on 2020-05-15
Reviewed by Geoffrey Garen.

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:
Use CFNetwork SPI to stop it from unlinking the downloaded file after resuming then completing.

Source/WebKit:

* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:]):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(TEST):
Add a short sleep (<1/10s) to make this test so it would've almost always failed without this fix.
Checking the file immediately usually succeeded, but waiting a few run loop iterations revealed that CFNetwork
was deleting resumed then finished downloads.

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (261761 => 261762)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-05-15 21:31:22 UTC (rev 261761)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-05-15 21:32:37 UTC (rev 261762)
@@ -1,3 +1,13 @@
+2020-05-15  Alex Christensen  <[email protected]>
+
+        [iOS Simulator] TestWebKitAPI._WKDownload.Resume is a flaky crash
+        https://bugs.webkit.org/show_bug.cgi?id=211786
+
+        Reviewed by Geoffrey Garen.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+        Use CFNetwork SPI to stop it from unlinking the downloaded file after resuming then completing.
+
 2020-05-12  Per Arne Vollan  <[email protected]>
 
         [iOS] Rebuild MobileGestalt cache if needed

Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (261761 => 261762)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2020-05-15 21:31:22 UTC (rev 261761)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2020-05-15 21:32:37 UTC (rev 261762)
@@ -425,6 +425,16 @@
 - (void)_setCookiesRemovedHandler:(void(^__nullable)(NSArray<NSHTTPCookie*>* __nullable removedCookies, NSString* __nullable domainForRemovedCookies, bool removeAllCookies))cookiesRemovedHandler onQueue:(dispatch_queue_t __nullable)queue;
 @end
 
+@interface __NSCFLocalDownloadFile
+@end
+@interface __NSCFLocalDownloadFile ()
+@property (readwrite, assign) BOOL skipUnlink;
+@end
+
+@interface NSURLSessionDownloadTask ()
+- (__NSCFLocalDownloadFile *)downloadFile;
+@end
+
 @interface NSURLResponse ()
 - (void)_setMIMEType:(NSString *)type;
 @end

Modified: trunk/Source/WebKit/ChangeLog (261761 => 261762)


--- trunk/Source/WebKit/ChangeLog	2020-05-15 21:31:22 UTC (rev 261761)
+++ trunk/Source/WebKit/ChangeLog	2020-05-15 21:32:37 UTC (rev 261762)
@@ -1,5 +1,15 @@
 2020-05-15  Alex Christensen  <[email protected]>
 
+        [iOS Simulator] TestWebKitAPI._WKDownload.Resume is a flaky crash
+        https://bugs.webkit.org/show_bug.cgi?id=211786
+
+        Reviewed by Geoffrey Garen.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:]):
+
+2020-05-15  Alex Christensen  <[email protected]>
+
         Regression (iOS 13.4, r249142): WKWebView.loading is never reset after a Back navigation in an iframe
         https://bugs.webkit.org/show_bug.cgi?id=211449
 

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (261761 => 261762)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-05-15 21:31:22 UTC (rev 261761)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-05-15 21:32:37 UTC (rev 261762)
@@ -955,7 +955,10 @@
 
 - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes
 {
-    notImplemented();
+#if PLATFORM(IOS_FAMILY)
+    // This is to work around rdar://problem/63249830
+    downloadTask.downloadFile.skipUnlink = YES;
+#endif
 }
 
 - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask

Modified: trunk/Tools/ChangeLog (261761 => 261762)


--- trunk/Tools/ChangeLog	2020-05-15 21:31:22 UTC (rev 261761)
+++ trunk/Tools/ChangeLog	2020-05-15 21:32:37 UTC (rev 261762)
@@ -1,5 +1,18 @@
 2020-05-15  Alex Christensen  <[email protected]>
 
+        [iOS Simulator] TestWebKitAPI._WKDownload.Resume is a flaky crash
+        https://bugs.webkit.org/show_bug.cgi?id=211786
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
+        (TEST):
+        Add a short sleep (<1/10s) to make this test so it would've almost always failed without this fix.
+        Checking the file immediately usually succeeded, but waiting a few run loop iterations revealed that CFNetwork
+        was deleting resumed then finished downloads.
+
+2020-05-15  Alex Christensen  <[email protected]>
+
         Regression (iOS 13.4, r249142): WKWebView.loading is never reset after a Back navigation in an iframe
         https://bugs.webkit.org/show_bug.cgi?id=211449
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm (261761 => 261762)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm	2020-05-15 21:31:22 UTC (rev 261761)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm	2020-05-15 21:32:37 UTC (rev 261762)
@@ -1279,6 +1279,12 @@
     EXPECT_EQ(callbacks[5], Callback::ReceiveData);
     EXPECT_EQ(callbacks[6], Callback::Finish);
 
+    // Give CFNetwork enough time to unlink the downloaded file if it would have.
+    // This makes failures like https://bugs.webkit.org/show_bug.cgi?id=211786 more reliable.
+    usleep(10000);
+    Util::spinRunLoop(10);
+    usleep(10000);
+
     NSData *fileContents = [NSData dataWithContentsOfURL:expectedDownloadFile];
     EXPECT_EQ(fileContents.length, 10000u);
     EXPECT_TRUE(fileContents.bytes);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to