Changeset 243947 in webkit
- Timestamp:
- Apr 5, 2019 2:52:51 PM (5 years ago)
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-607-branch/Tools/ChangeLog
r243946 r243947 1 2019-04-05 Alex Christensen <achristensen@webkit.org> 2 3 REGRESSION(AppleWebKit/605.1.15): WebDownloadDelegate delegate methods called on non-main thread 4 https://bugs.webkit.org/show_bug.cgi?id=190918 5 <rdar://problem/45603890> 6 7 Reviewed by Darin Adler. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitLegacy/mac/DownloadThread.mm: Added. 11 (-[DownloadThreadChecker webView:decidePolicyForMIMEType:request:frame:decisionListener:]): 12 (-[DownloadThreadChecker downloadDidBegin:]): 13 (-[DownloadThreadChecker download:shouldDecodeSourceDataOfMIMEType:]): 14 (-[DownloadThreadChecker download:decideDestinationWithSuggestedFilename:]): 15 (-[DownloadThreadChecker download:didCreateDestination:]): 16 (-[DownloadThreadChecker downloadDidFinish:]): 17 (TestWebKitAPI::TEST): 18 1 19 2019-04-05 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Source/WebKitLegacy/mac/ChangeLog
r243944 r243947 1 2019-04-05 Alex Christensen <achristensen@webkit.org> 2 3 REGRESSION(AppleWebKit/605.1.15): WebDownloadDelegate delegate methods called on non-main thread 4 https://bugs.webkit.org/show_bug.cgi?id=190918 5 <rdar://problem/45603890> 6 7 Reviewed by Darin Adler. 8 9 Since we not doing networking on the main thread but WebView is to be used on the main thread, 10 we need to hop delegate calls to the main thread similarly to how we do it in the non-download 11 delegate calls in WebCoreResourceHandleAsOperationQueueDelegate. 12 13 * Misc/WebDownload.mm: 14 (-[WebDownloadInternal downloadDidBegin:]): 15 (-[WebDownloadInternal download:willSendRequest:redirectResponse:]): 16 (-[WebDownloadInternal download:didReceiveAuthenticationChallenge:]): 17 (-[WebDownloadInternal download:didReceiveResponse:]): 18 (-[WebDownloadInternal download:didReceiveDataOfLength:]): 19 (-[WebDownloadInternal download:shouldDecodeSourceDataOfMIMEType:]): 20 (-[WebDownloadInternal download:decideDestinationWithSuggestedFilename:]): 21 (-[WebDownloadInternal download:didCreateDestination:]): 22 (-[WebDownloadInternal downloadDidFinish:]): 23 (-[WebDownloadInternal download:didFailWithError:]): 24 1 25 2019-04-05 Eric Carlson <eric.carlson@apple.com> 2 26 -
trunk/Source/WebKitLegacy/mac/Misc/WebDownload.mm
r240292 r243947 40 40 #import <pal/spi/cocoa/NSURLDownloadSPI.h> 41 41 #import <wtf/Assertions.h> 42 #import <wtf/MainThread.h> 42 43 43 44 using namespace WebCore; … … 83 84 - (void)downloadDidBegin:(NSURLDownload *)download 84 85 { 85 [realDelegate downloadDidBegin:download]; 86 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download)] { 87 [realDelegate downloadDidBegin:download.get()]; 88 }); 86 89 } 87 90 88 91 - (NSURLRequest *)download:(NSURLDownload *)download willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse 89 92 { 90 return [realDelegate download:download willSendRequest:request redirectResponse:redirectResponse]; 93 RetainPtr<NSURLRequest> returnValue; 94 auto work = [&] { 95 ASSERT(isMainThread()); 96 returnValue = [realDelegate download:download willSendRequest:request redirectResponse:redirectResponse]; 97 }; 98 if (isMainThread()) 99 work(); 100 else 101 dispatch_sync(dispatch_get_main_queue(), work); 102 return returnValue.autorelease(); 91 103 } 92 104 … … 104 116 105 117 if ([realDelegate respondsToSelector:@selector(download:didReceiveAuthenticationChallenge:)]) { 106 [realDelegate download:download didReceiveAuthenticationChallenge:challenge]; 118 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download), challenge = retainPtr(challenge)] { 119 [realDelegate download:download.get() didReceiveAuthenticationChallenge:challenge.get()]; 120 }); 107 121 } else { 108 NSWindow *window = nil; 109 if ([realDelegate respondsToSelector:@selector(downloadWindowForAuthenticationSheet:)]) { 110 window = [realDelegate downloadWindowForAuthenticationSheet:(WebDownload *)download]; 111 } 112 113 [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window]; 122 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download), challenge = retainPtr(challenge)] { 123 NSWindow *window = nil; 124 if ([realDelegate respondsToSelector:@selector(downloadWindowForAuthenticationSheet:)]) 125 window = [realDelegate downloadWindowForAuthenticationSheet:(WebDownload *)download.get()]; 126 127 [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge.get() window:window]; 128 }); 114 129 } 115 130 #endif … … 118 133 - (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response 119 134 { 120 [realDelegate download:download didReceiveResponse:response]; 135 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download), response = retainPtr(response)] { 136 [realDelegate download:download.get() didReceiveResponse:response.get()]; 137 }); 121 138 } 122 139 123 140 - (void)download:(NSURLDownload *)download didReceiveDataOfLength:(NSUInteger)length 124 141 { 125 [realDelegate download:download didReceiveDataOfLength:length]; 142 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download), length] { 143 [realDelegate download:download.get() didReceiveDataOfLength:length]; 144 }); 126 145 } 127 146 128 147 - (BOOL)download:(NSURLDownload *)download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType 129 148 { 130 return [realDelegate download:download shouldDecodeSourceDataOfMIMEType:encodingType]; 149 BOOL returnValue = NO; 150 auto work = [&] { 151 returnValue = [realDelegate download:download shouldDecodeSourceDataOfMIMEType:encodingType]; 152 }; 153 if (isMainThread()) 154 work(); 155 else 156 dispatch_sync(dispatch_get_main_queue(), work); 157 return returnValue; 131 158 } 132 159 133 160 - (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename 134 161 { 135 [realDelegate download:download decideDestinationWithSuggestedFilename:filename]; 162 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download), filename = retainPtr(filename)] { 163 [realDelegate download:download.get() decideDestinationWithSuggestedFilename:filename.get()]; 164 }); 136 165 } 137 166 138 167 - (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path 139 168 { 140 [realDelegate download:download didCreateDestination:path]; 169 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download), path = retainPtr(path)] { 170 [realDelegate download:download.get() didCreateDestination:path.get()]; 171 }); 141 172 } 142 173 143 174 - (void)downloadDidFinish:(NSURLDownload *)download 144 175 { 145 [realDelegate downloadDidFinish:download]; 176 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download)] { 177 [realDelegate downloadDidFinish:download.get()]; 178 }); 146 179 } 147 180 148 181 - (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error 149 182 { 150 [realDelegate download:download didFailWithError:error]; 183 callOnMainThread([realDelegate = retainPtr(realDelegate), download = retainPtr(download), error = retainPtr(error)] { 184 [realDelegate download:download.get() didFailWithError:error.get()]; 185 }); 151 186 } 152 187 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r243797 r243947 341 341 5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; }; 342 342 5CEAB5E11FA939F400A77FAA /* _WKInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */; }; 343 5CF540E92257E67C00E6BC0E /* DownloadThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */; }; 343 344 5E4B1D2E1D404C6100053621 /* WKScrollViewDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */; }; 344 345 631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */; }; … … 1749 1750 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; }; 1750 1751 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInputDelegate.mm; sourceTree = "<group>"; }; 1752 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadThread.mm; sourceTree = "<group>"; }; 1751 1753 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegate.mm; path = ../ios/WKScrollViewDelegate.mm; sourceTree = "<group>"; }; 1752 1754 631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Geolocation.mm; sourceTree = "<group>"; }; … … 2856 2858 9BD5111B1FE8E11600D2B630 /* AccessingPastedImage.mm */, 2857 2859 6B306105218A372900F5A802 /* ClosingWebView.mm */, 2860 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */, 2858 2861 5C6E27A6224EEBEA00128736 /* URLCanonicalization.mm */, 2859 2862 ); … … 4078 4081 7CCE7EEE1A411AE600447C4C /* DownloadDecideDestinationCrash.cpp in Sources */, 4079 4082 637281A721AE1386009E0DE6 /* DownloadProgress.mm in Sources */, 4083 5CF540E92257E67C00E6BC0E /* DownloadThread.mm in Sources */, 4080 4084 F4D4F3B61E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm in Sources */, 4081 4085 F46128B7211C8ED500D9FADB /* DragAndDropSimulatorMac.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.