Bug 202825 - Only use CFNetwork SPI for metrics where needed
Summary: Only use CFNetwork SPI for metrics where needed
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
: 198762 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-10-10 14:35 PDT by Alex Christensen
Modified: 2020-03-08 12:53 PDT (History)
11 users (show)

See Also:


Attachments
Patch (6.24 KB, patch)
2019-10-10 14:35 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (9.41 KB, patch)
2019-10-11 11:17 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (9.34 KB, patch)
2019-10-11 11:38 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2019-10-10 14:35:24 PDT
Only use CFNetwork SPI for metrics where needed
Comment 1 Alex Christensen 2019-10-10 14:35:51 PDT
Created attachment 380685 [details]
Patch
Comment 2 Joseph Pecoraro 2019-10-10 17:51:00 PDT
Comment on attachment 380685 [details]
Patch

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

r=me

The first time we tried this (bug 198762) got rolled out in r247095. Just make sure this test continues to pass!
http/tests/inspector/network/har/har-page.html

> Source/WTF/wtf/Platform.h:1521
> +#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
> +#define HAVE_CFNETWORK_METRICS 1
> +#endif

Nit: I believe Keith Rollins was just investigating if we should enable these for tvOS / watchOS. The APIs do exist there, so I suggest we do that. Maybe you can sync up with him on how best to do that, but that doesn't block this.

I'd probably have named this positive for "APIs" since older builds have the "SPIs". So maybe something like HAVE_CFNETWORK_METRICS_APIS_V4? I'd leave that up to you.

> Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:710
> +            networkLoadMetrics.tlsCipher = stringForSSLCipher((SSLCipherSuite)[m.negotiatedTLSCipherSuite unsignedShortValue]);

Shouldn't this be a `tls_ciphersuite_t` not a `SSLCipherSuite`? Or are they interchangeable?

> Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:734
>              for (NSURLSessionTaskTransactionMetrics *transactionMetrics in metrics.transactionMetrics) {
> +#if HAVE(CFNETWORK_METRICS)
> +                requestHeaderBytesSent += transactionMetrics.countOfRequestHeaderBytesSent;
> +                responseHeaderBytesReceived += transactionMetrics.countOfResponseHeaderBytesReceived;
> +                responseBodyBytesReceived += transactionMetrics.countOfResponseBodyBytesReceived;
> +                responseBodyDecodedSize += transactionMetrics.countOfResponseBodyBytesAfterDecoding ? transactionMetrics.countOfResponseBodyBytesAfterDecoding : transactionMetrics.countOfResponseBodyBytesReceived;
> +#else

Not significant but we should probably update NetworkLoadMetrics's values here from uint32_ts to uint64_ts. This was done in the first attempt to use the CFNetwork APIs:
https://bugs.webkit.org/attachment.cgi?id=371875&action=review

```
    uint32_t requestHeaderBytesSent;
    uint32_t responseHeaderBytesReceived;
```

The CFNetwork APIs here are `int64_t` and the SPIs here were `NSInteger`. So it seems a >32bit number could happen.
Comment 3 Alex Christensen 2019-10-11 11:17:25 PDT
Created attachment 380769 [details]
Patch
Comment 4 Alex Christensen 2019-10-11 11:38:17 PDT
Created attachment 380772 [details]
Patch
Comment 5 Joseph Pecoraro 2019-10-11 13:36:57 PDT
*** Bug 198762 has been marked as a duplicate of this bug. ***
Comment 6 WebKit Commit Bot 2019-10-11 13:38:17 PDT
Comment on attachment 380772 [details]
Patch

Clearing flags on attachment: 380772

Committed r251021: <https://trac.webkit.org/changeset/251021>
Comment 7 WebKit Commit Bot 2019-10-11 13:38:19 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2019-10-15 16:47:01 PDT
<rdar://problem/56313694>
Comment 9 Tim Horton 2020-03-08 12:53:29 PDT
Comment on attachment 380772 [details]
Patch

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

> Source/WTF/wtf/Platform.h:1519
> +#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)

FWIW "PLATFORM(IOS_FAMILY) && only testing an IPHONE_OS version" is always wrong. This is disabled on all non-iOS iOS-family platforms.