WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
Bug 158463
Network: Correctly report encoded data length (transfer size) from CFNetwork to NetworkResourceLoader
https://bugs.webkit.org/show_bug.cgi?id=158463
Summary
Network: Correctly report encoded data length (transfer size) from CFNetwork ...
Alex Christensen
Reported
2016-06-06 22:42:50 PDT
Correctly report encoded data length from CFNetwork to NetworkResourceLoader
Attachments
Patch
(10.20 KB, patch)
2016-06-06 22:49 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(10.22 KB, patch)
2016-06-07 09:51 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(48.38 KB, patch)
2016-06-07 18:14 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(51.03 KB, patch)
2016-06-07 22:11 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(52.47 KB, patch)
2016-06-07 23:06 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(58.74 KB, patch)
2016-06-08 00:08 PDT
,
Alex Christensen
achristensen
: review-
Details
Formatted Diff
Diff
[PATCH] Work in Progress
(53.42 KB, patch)
2017-07-03 18:55 PDT
,
Joseph Pecoraro
joepeck
: review-
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Alex Christensen
Comment 1
2016-06-06 22:49:15 PDT
Created
attachment 280676
[details]
Patch
Alex Christensen
Comment 2
2016-06-07 09:51:22 PDT
Created
attachment 280715
[details]
Patch
Darin Adler
Comment 3
2016-06-07 15:17:13 PDT
Comment on
attachment 280715
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=280715&action=review
> Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:263 > + m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::wrapNSData(data), static_cast<int>(lengthReceived));
This chops a 64-bit integer and turns it into a 32-bit integer. Why is that OK?
> Source/WebKit2/NetworkProcess/NetworkLoad.cpp:252 > +void NetworkLoad::didReceiveData(RefPtr<SharedBuffer>&& buffer, int64_t encodedDataLength)
How did you choose the type int64_t? Why signed rather than unsigned? Also, other places in the code use “[unsigned] long long” for this.
> Source/WebKit2/NetworkProcess/NetworkLoad.cpp:255 > + m_client.didReceiveBuffer(WTFMove(buffer), static_cast<int>(encodedDataLength));
This chops a 64-bit integer and turns it into a 32-bit integer. Why is that OK?
Alex Christensen
Comment 4
2016-06-07 15:38:47 PDT
(In reply to
comment #3
)
> Comment on
attachment 280715
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=280715&action=review
> > > Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:263 > > + m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::wrapNSData(data), static_cast<int>(lengthReceived)); > > This chops a 64-bit integer and turns it into a 32-bit integer. Why is that > OK?
There is great inconsistency in how this is passed around. It should be fixed.
> > > Source/WebKit2/NetworkProcess/NetworkLoad.cpp:252 > > +void NetworkLoad::didReceiveData(RefPtr<SharedBuffer>&& buffer, int64_t encodedDataLength) > > How did you choose the type int64_t? Why signed rather than unsigned? Also, > other places in the code use “[unsigned] long long” for this.
That's what is used in NSURLSession.h. @property (readonly) int64_t countOfBytesReceived; There's a comment saying it can be 0 or -1.
Alex Christensen
Comment 5
2016-06-07 16:14:09 PDT
rdar://problem/21319035
Alex Christensen
Comment 6
2016-06-07 18:14:52 PDT
Created
attachment 280756
[details]
Patch
Alex Christensen
Comment 7
2016-06-07 22:11:08 PDT
Created
attachment 280769
[details]
Patch
Alex Christensen
Comment 8
2016-06-07 23:06:41 PDT
Created
attachment 280774
[details]
Patch
Alex Christensen
Comment 9
2016-06-08 00:08:39 PDT
Created
attachment 280784
[details]
Patch
Alex Christensen
Comment 10
2016-06-08 11:47:26 PDT
Comment on
attachment 280784
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=280784&action=review
> Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm:265 > + networkDataTask->didReceiveData(WebCore::SharedBuffer::wrapNSData(data), [dataTask countOfBytesReceived]);
[dataTask countOfBytesReceived] returns the decoded size, not the encoded size. That's exactly the same as the sum of the previous data->size()s. This gives us no additional information.
Darin Adler
Comment 11
2016-06-09 20:00:43 PDT
Comment on
attachment 280715
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=280715&action=review
>>> Source/WebKit2/NetworkProcess/NetworkLoad.cpp:252 >>> +void NetworkLoad::didReceiveData(RefPtr<SharedBuffer>&& buffer, int64_t encodedDataLength) >> >> How did you choose the type int64_t? Why signed rather than unsigned? Also, other places in the code use “[unsigned] long long” for this. > > That's what is used in NSURLSession.h. > @property (readonly) int64_t countOfBytesReceived; > There's a comment saying it can be 0 or -1.
OK, but for future reference, that doesn’t make it the correct type for platform-independent code.
Joseph Pecoraro
Comment 12
2017-04-12 18:38:31 PDT
<
rdar://problem/27927293
>
Joseph Pecoraro
Comment 13
2017-07-03 11:11:23 PDT
> Comment on
attachment 280784
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=280784&action=review
> > > Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm:265 > > + networkDataTask->didReceiveData(WebCore::SharedBuffer::wrapNSData(data), [dataTask countOfBytesReceived]); > > [dataTask countOfBytesReceived] returns the decoded size, not the encoded > size. That's exactly the same as the sum of the previous data->size()s. > This gives us no additional information.
There is a new SPI we should be able to use now to get the encoded size: -[NSURLSessionTask _countOfBytesReceivedEncoded] I'll update the patch.
Joseph Pecoraro
Comment 14
2017-07-03 13:10:52 PDT
Comment on
attachment 280784
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=280784&action=review
> Source/WebKit/WebCoreSupport/WebResourceLoadScheduler.cpp:94 > WebResourceLoadScheduler::~WebResourceLoadScheduler() > { > + // FIXME: Why isn't m_nonHTTPProtocolHost deleted? > }
It looks like this should delete the host, but I think the WebResourceLoadScheduler (owned by the PlatformStrategy) is never be destroyed. This could move to a separate issue.
Joseph Pecoraro
Comment 15
2017-07-03 18:55:02 PDT
Created
attachment 314544
[details]
[PATCH] Work in Progress I don't think the new SPI is enough. But I'm attaching my work in progress so it doesn't get lost.
Joseph Pecoraro
Comment 16
2017-07-03 18:56:40 PDT
Comment on
attachment 314544
[details]
[PATCH] Work in Progress View in context:
https://bugs.webkit.org/attachment.cgi?id=314544&action=review
> Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm:405 > + if ([dataTask respondsToSelector:@selector(_countOfBytesReceivedEncoded)]) { > + WTFLogAlways(">>> didReceiveData (%u) (%u)", (unsigned)dataTask._countOfBytesReceivedEncoded, (unsigned)dataTask.countOfBytesReceived); > + bytesReceived = dataTask._countOfBytesReceivedEncoded ?: dataTask.countOfBytesReceived; > + }
This is not good enough. 1. If the response is encoded (compressed) data, then _countOfBytesReceivedEncoded starts with zero and doesn't include headers... 2. If the response is uncompressed data, then countOfBytesReceived starts with non-zero and includes the header size. So without knowing if we are receiving compressed / uncompressed data we can't know which set of APIs to use.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug