Initially reported this as a bug to WebKit Bugzilla (
https://bugs.webkit.org/show_bug.cgi?id=190918) but it was cloned over to
Radar (rdar://problem/45603890). Thought I would add it here to see if
anyone has any ideas. The Xcode project is too big to attach to the mailing
list post.

Nick

When using the older WebView API to build a simple application that can
download files the thread that the WebDownloadDelegate methods are called
on changed between AppleWebKit/604.5.6 and AppleWebKit/605.1.15. I have
confirmed that the issue still occurs with r237410.

I have attached a very simple (and hacked together) macOS Xcode project
that shows the problem when downloading WebKit Build Archives from
https://webkit.org/build-archives

In the attached project all of the code that exercises the bug is in
WindowController.m. First, there is an implementation of
-[WebPolicyDelegate
webView:decidePolicyForMIMEType:request:frame:decisionListener:] that
checks for the MIME type "binary/octet-stream" and calls
-[WebPolicyDecisionListener download] for that MIME type (and -use for all
others). This method is called on the main thread as expected.

So running the application and clicking on a WebKit Build Archive will
result in the WebDownloadDelegate methods getting called. Before
AppleWebKit/605.1.15, in my case macOS Sierra 10.12.6 (16G1510) with
AppleWebKit/603.3.8, all of the WebDownloadDelegate methods are called on
the main thread as expected. Under AppleWebKit/605.1.15, macOS High Sierra
10.13.6 or above including macOS Mojave, the following WebDownloadDelegate
methods are called on the main thread:

- (void)downloadDidBegin:(NSURLDownload *)download;
- (void)downloadDidFinish:(NSURLDownload *)download;

Unfortunately, the following delegate methods are called on a different
thread:

- (void)download:(NSURLDownload *)download
decideDestinationWithSuggestedFilename:(NSString *)filename;
- (void)download:(NSURLDownload *)download didCreateDestination:(NSString
*)path;

Which thread the following are called on is unknown (untested):
- (BOOL)download:(NSURLDownload *)download
shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType;
- (void)download:(NSURLDownload *)download didFailWithError:(NSError
*)error;
- (NSWindow *)downloadWindowForAuthenticationSheet:(WebDownload *)download;

My testing on macOS High Sierra 10.13.6 (17G64) the thread that
-download:decideDestinationWithSuggestedFilename: and
-download:didCreateDestination: are called on is an NSURLConnection thread
(enqueued in order from com.apple.network.connections,
com.apple.CFNetwork.Connection, com.apple.NSURLSession-work).

I have confirmed that this also occurs with AppleWebKit/605.1.15 running on
macOS Mojave 10.14 and on macOS Sierra 10.12.6 when I use the r237410
WebKit Build Archive to launch the test application. During testing I
initially installed macOS High Sierra 10.13.3 which includes
AppleWebKit/604.5.6 which does not have this issue so the regression
happened between 604.5.6 and 605.1.15.

While the attached test application does not crash, the application that
this was originally reported against does because it calls WebKit from one
of the delegate methods that no longer get called back on the main thread.
I am able to workaround this issue by calling -[NSObject
performSelectorOnMainThread:withObject:waitUntilDone:]
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to