Skip to content
Permalink
Browse files
Crash in imported/w3c/web-platform-tests/2dcontext/imagebitmap/create…
…ImageBitmap-origin.sub.html

https://bugs.webkit.org/show_bug.cgi?id=182422
<rdar://problem/37182665>

Patch by Youenn Fablet <youenn@apple.com> on 2018-02-05
Reviewed by Alex Christensen.

Source/WebCore:

Covered by test no longer crashing in Debug mode.
Make sure completionHandler is called on the main thread.

* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:completionHandler:]):

LayoutTests:

* platform/mac/TestExpectations:

Canonical link: https://commits.webkit.org/198319@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf authored and webkit-commit-queue committed Feb 6, 2018
1 parent 5800b10 commit 0883b4093e69fa7aff099897e149322e13374a0d
Showing with 45 additions and 6 deletions.
  1. +10 −0 LayoutTests/ChangeLog
  2. +1 −1 LayoutTests/platform/mac/TestExpectations
  3. +14 −0 Source/WebCore/ChangeLog
  4. +20 −5 Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm
@@ -1,3 +1,13 @@
2018-02-05 Youenn Fablet <youenn@apple.com>

Crash in imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html
https://bugs.webkit.org/show_bug.cgi?id=182422
<rdar://problem/37182665>

Reviewed by Alex Christensen.

* platform/mac/TestExpectations:

2018-02-05 Myles C. Maxfield <mmaxfield@apple.com>

Test gardening after r228044
@@ -1740,4 +1740,4 @@ webkit.org/b/181969 fast/events/message-port.html [ Skip ]
webkit.org/b/181831 [ HighSierra+ ] fast/forms/searchfield-heights.html [ Pass Failure ]

webkit.org/b/182422 imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html [ Pass Failure ]
webkit.org/b/182422 imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html [ Skip ]
webkit.org/b/182422 imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html [ Pass Failure ]
@@ -1,3 +1,17 @@
2018-02-05 Youenn Fablet <youenn@apple.com>

Crash in imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html
https://bugs.webkit.org/show_bug.cgi?id=182422
<rdar://problem/37182665>

Reviewed by Alex Christensen.

Covered by test no longer crashing in Debug mode.
Make sure completionHandler is called on the main thread.

* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:completionHandler:]):

2018-02-05 Filip Pizlo <fpizlo@apple.com>

Global objects should be able to use TLCs to allocate from different blocks from each other
@@ -389,7 +389,10 @@ - (BOOL)isKindOfClass:(Class)aClass

void WebCoreNSURLSessionDataTaskClient::redirectReceived(PlatformMediaResource& resource, ResourceRequest&& request, const ResourceResponse& response, CompletionHandler<void(ResourceRequest&&)>&& completionHandler)
{
[m_task resource:resource receivedRedirect:response request:WTFMove(request) completionHandler:WTFMove(completionHandler)];
[m_task resource:resource receivedRedirect:response request:WTFMove(request) completionHandler: [completionHandler = WTFMove(completionHandler)] (auto&& request) {
ASSERT(isMainThread());
completionHandler(WTFMove(request));
}];
}

void WebCoreNSURLSessionDataTaskClient::accessControlCheckFailed(PlatformMediaResource& resource, const ResourceError& error)
@@ -618,20 +621,32 @@ - (void)resource:(PlatformMediaResource&)resource receivedData:(const char*)data
- (void)resource:(PlatformMediaResource&)resource receivedRedirect:(const ResourceResponse&)response request:(ResourceRequest&&)request completionHandler:(CompletionHandler<void(ResourceRequest&&)>&&)completionHandler
{
ASSERT_UNUSED(resource, &resource == _resource);
[self.session addDelegateOperation:[strongSelf = retainPtr(self), response = retainPtr(response.nsURLResponse()), request = WTFMove(request), completionHandler = WTFMove(completionHandler)] () mutable {
[self.session addDelegateOperation:[strongSelf = retainPtr(self), response = retainPtr(response.nsURLResponse()), request = request.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
ASSERT_NOT_REACHED();
return completionHandler(WTFMove(request));
callOnMainThread([request = WTFMove(request), completionHandler = WTFMove(completionHandler)] () mutable {
completionHandler(WTFMove(request));
});
return;
}

id<NSURLSessionDataDelegate> dataDelegate = (id<NSURLSessionDataDelegate>)strongSelf.get().session.delegate;
if ([dataDelegate respondsToSelector:@selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)]) {
auto completionHandlerBlock = BlockPtr<void(NSURLRequest *)>::fromCallable([completionHandler = WTFMove(completionHandler)](NSURLRequest *newRequest) mutable {
if (!isMainThread()) {
callOnMainThread([request = ResourceRequest { newRequest }, completionHandler = WTFMove(completionHandler)] () mutable {
completionHandler(WTFMove(request));
});
return;
}
completionHandler(newRequest);
});
[dataDelegate URLSession:(NSURLSession *)strongSelf.get().session task:(NSURLSessionTask *)strongSelf.get() willPerformHTTPRedirection:(NSHTTPURLResponse *)response.get() newRequest:request.nsURLRequest(DoNotUpdateHTTPBody) completionHandler:completionHandlerBlock.get()];
} else
completionHandler(WTFMove(request));
} else {
callOnMainThread([request = WTFMove(request), completionHandler = WTFMove(completionHandler)] () mutable {
completionHandler(WTFMove(request));
});
}
}];
}

0 comments on commit 0883b40

Please sign in to comment.