Bug 220981 - Load data URLs in the web process also for synchronous loads
Summary: Load data URLs in the web process also for synchronous loads
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
: 221023 (view as bug list)
Depends on:
Blocks: 220764
  Show dependency treegraph
 
Reported: 2021-01-26 07:32 PST by Carlos Garcia Campos
Modified: 2021-01-28 04:41 PST (History)
11 users (show)

See Also:


Attachments
Patch (15.19 KB, patch)
2021-01-26 07:41 PST, Carlos Garcia Campos
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (16.87 KB, patch)
2021-01-27 03:55 PST, Carlos Garcia Campos
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (16.88 KB, patch)
2021-01-27 04:03 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (19.16 KB, patch)
2021-01-27 04:10 PST, Carlos Garcia Campos
aperez: review+
achristensen: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (21.33 KB, patch)
2021-01-28 03:08 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2021-01-26 07:32:52 PST
In r271879 I removed the support for data URLs in the network process for soup, assuming data URLs were always loaded from the web process, but that's not the case for synchronous loads. We don't need to go to the network process for sync loads.
Comment 1 Carlos Garcia Campos 2021-01-26 07:41:12 PST
Created attachment 418418 [details]
Patch
Comment 2 Carlos Garcia Campos 2021-01-26 07:49:46 PST
It seems it's failing to find <WebCore/DataURLDecoder.h>. Aren't forwarding headers automatic in mac? I added the header to Source/WebCore/Headers.cmake
Comment 3 Carlos Garcia Campos 2021-01-27 00:40:08 PST
*** Bug 221023 has been marked as a duplicate of this bug. ***
Comment 4 Carlos Garcia Campos 2021-01-27 03:55:18 PST
Created attachment 418525 [details]
Patch
Comment 5 Carlos Garcia Campos 2021-01-27 04:03:23 PST
Created attachment 418526 [details]
Patch
Comment 6 Carlos Garcia Campos 2021-01-27 04:10:30 PST
Created attachment 418528 [details]
Patch
Comment 7 Alex Christensen 2021-01-27 15:01:22 PST
Comment on attachment 418528 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=418528&action=review

> Source/WebCore/platform/network/DataURLDecoder.cpp:221
> +    bool success = task->process();

I don't think we need a local variable here.  I think the function logic would look simpler like this:

if (!task->process())
    return WTF::nullopt;
if (task->isBase64) {
    if (!decodeBase64(*task, mode))
        return WTF::nullopt;
} else
    decodeEscaped(*task);
return WTFMove(task->result);

Also, this whole thing is duplicate code.  I think this function should be called decodeSynchronously and decode should call it.

> Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:547
> +    result.response.setHTTPStatusCode(200);

This is adding duplicate code with ResourceLoader::loadDataURL.  Could we make them share code?

> Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:601
> +        auto syncLoadResult = loadDataURLSynchronously(request);

WebLoaderStrategy::loadResourceSynchronously should return a SyncLoadResult instead of taking error, response, and data as out params.
Comment 8 Carlos Garcia Campos 2021-01-28 03:00:55 PST
Comment on attachment 418528 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=418528&action=review

>> Source/WebCore/platform/network/DataURLDecoder.cpp:221
>> +    bool success = task->process();
> 
> I don't think we need a local variable here.  I think the function logic would look simpler like this:
> 
> if (!task->process())
>     return WTF::nullopt;
> if (task->isBase64) {
>     if (!decodeBase64(*task, mode))
>         return WTF::nullopt;
> } else
>     decodeEscaped(*task);
> return WTFMove(task->result);
> 
> Also, this whole thing is duplicate code.  I think this function should be called decodeSynchronously and decode should call it.

Ok, I'll moved the common parts, the whole function can't be used from the async function because the task creation is different.

>> Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:547
>> +    result.response.setHTTPStatusCode(200);
> 
> This is adding duplicate code with ResourceLoader::loadDataURL.  Could we make them share code?

Yes.

>> Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:601
>> +        auto syncLoadResult = loadDataURLSynchronously(request);
> 
> WebLoaderStrategy::loadResourceSynchronously should return a SyncLoadResult instead of taking error, response, and data as out params.

SyncLoadResult is private. We could make it public and update all the callers, but I think that refactoring is out of scope of this bug.
Comment 9 Carlos Garcia Campos 2021-01-28 03:08:25 PST
Created attachment 418633 [details]
Patch for landing
Comment 10 Carlos Garcia Campos 2021-01-28 04:40:54 PST
Committed r272009: <https://trac.webkit.org/changeset/272009>
Comment 11 Radar WebKit Bug Importer 2021-01-28 04:41:15 PST
<rdar://problem/73704517>