How can I solve the 'This task has already been stopped' crash when using WKURLSchemeHandler with WKWebView?

139 Views Asked by At

I start to use WKURLSchemeHandler to intercept offline resource, in order to replace NSURLProtocol. However, when I handle the H5 request and it frequently occurred "This task has already been stopped" crash.

enter image description here

here is the crash demo: https://github.com/lllhf/testWK.git

set your own bundle identifier and team, while running the project on iPhone(not simulator), continuous click the "Test XHR" or "Test Fetch", then crash happened.

I wonder why it crashed, since I've checked the requestTask and urlSchemeTask. I don't know which task has been stopped, what type is the task.

Thanks for all of you help me figure out this problem.

I've tried: 1, check the requestTask and urlSchemeTask, make sure their state is useful. 2, print so many log to find.(not show in the demo..

Expected: solve the crash and find out which task has been stopped and why.

0

There are 0 best solutions below