WKURLSchemeTaskImpl instances are being abandoned (except if the task is stopped).
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jul 2017 20:03:42 +0000 (20:03 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jul 2017 20:03:42 +0000 (20:03 +0000)
commit32a122d39dfe65d0d88f2e47e41d5dff410e3b90
tree25b58fe0899b9566b149dba629d6615e291ec961
parent16fc4abf8f01cea065c971bbc7fbccd39a5e4e13
WKURLSchemeTaskImpl instances are being abandoned (except if the task is stopped).
<rdar://problem/33568276> and https://bugs.webkit.org/show_bug.cgi?id=174895

Reviewed by Alex Christensen.

There was a lot going on here:
- There was an unbroken cycle between URLSchemeHandlers and URLSchemeTasks
- WKURLSchemeTasks were not destroying their API::URLSchemeTask implementation object
- When a WKWebView was dealloc'ed, it was not cleaning up the related UIProcess tasks
- If the NetworkingProcess crashed, WebProcesses were not cleaning up their tasks
  (and therefore the UIProcess tasks were also not getting cleaned up)
- If a WebProcess crashed, the UIProcess was not cleaning up the related tasks

* UIProcess/API/Cocoa/WKURLSchemeTask.mm:
(-[WKURLSchemeTaskImpl dealloc]): Call API::~URLSchemeTask

* UIProcess/Cocoa/WebURLSchemeHandlerCocoa.h:
* UIProcess/Cocoa/WebURLSchemeHandlerCocoa.mm:
(WebKit::WebURLSchemeHandlerCocoa::platformTaskCompleted): Clear out the API wrapper map
  so the wrapper and implementation object can both be destroyed.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close): Call stopAllURLSchemeTasks.
(WebKit::WebPageProxy::processDidTerminate): Call stopAllURLSchemeTasks.
(WebKit::WebPageProxy::stopAllURLSchemeTasks):
* UIProcess/WebPageProxy.h:

* UIProcess/WebURLSchemeHandler.cpp:
(WebKit::WebURLSchemeHandler::startTask):
(WebKit::WebURLSchemeHandler::stopAllTasksForPage):
(WebKit::WebURLSchemeHandler::stopTask):
(WebKit::WebURLSchemeHandler::taskCompleted):
* UIProcess/WebURLSchemeHandler.h:

* UIProcess/WebURLSchemeTask.cpp:
(WebKit::WebURLSchemeTask::WebURLSchemeTask):
* UIProcess/WebURLSchemeTask.h:
(WebKit::WebURLSchemeTask::pageID): Store separate from the WebPage so messaging
  is possible even after the WebPage* has been cleared.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::stopAllURLSchemeTasks):
* WebProcess/WebPage/WebPage.h:

* WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp:
(WebKit::WebURLSchemeHandlerProxy::stopAllTasks):
(WebKit::WebURLSchemeHandlerProxy::taskDidComplete):
(WebKit::WebURLSchemeHandlerProxy::taskDidStopLoading):
(WebKit::WebURLSchemeHandlerProxy::removeTask):
* WebProcess/WebPage/WebURLSchemeHandlerProxy.h:

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::networkProcessConnectionClosed): Call stopAllURLSchemeTasks
  for each WebPage.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220011 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKURLSchemeTask.mm
Source/WebKit/UIProcess/Cocoa/WebURLSchemeHandlerCocoa.h
Source/WebKit/UIProcess/Cocoa/WebURLSchemeHandlerCocoa.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebURLSchemeHandler.cpp
Source/WebKit/UIProcess/WebURLSchemeHandler.h
Source/WebKit/UIProcess/WebURLSchemeTask.cpp
Source/WebKit/UIProcess/WebURLSchemeTask.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp
Source/WebKit/WebProcess/WebPage/WebURLSchemeHandlerProxy.h
Source/WebKit/WebProcess/WebProcess.cpp