Repository navigation
[cronet_http] Add QUIC options and the remaining DNS options to CronetEngine.build - #2115
brahim-guaali wants to merge 3 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request adds support for additional DNS options (preestablishConnectionsToStaleDnsResults, freshLookupTimeout) and QUIC options (enableTlsZeroRtt, retryWithoutAltSvcOnQuicErrors, delayJobsWithAvailableSpdySession, cryptoHandshakeTimeout) to CronetEngine.build, along with integration tests. Feedback is provided to add validation for cryptoHandshakeTimeout to ensure it is at least 1 second, as sub-second durations would otherwise be silently truncated to 0 and cause failures.
| if (cryptoHandshakeTimeout != null) { | ||
| quicOptionsBuilder | ||
| .setCryptoHandshakeTimeoutSeconds( | ||
| cryptoHandshakeTimeout.inSeconds) | ||
| ?.release(); | ||
| } |
There was a problem hiding this comment.
Since cryptoHandshakeTimeout is specified as a Duration but Cronet's setCryptoHandshakeTimeoutSeconds only accepts whole seconds, any sub-second duration (e.g., Duration(milliseconds: 500)) will be silently truncated to 0 seconds. A handshake timeout of 0 or less is invalid and will likely cause immediate failures or unexpected behavior.
Consider adding a validation check to ensure that cryptoHandshakeTimeout is at least 1 second.
if (cryptoHandshakeTimeout != null) {
if (cryptoHandshakeTimeout.inSeconds <= 0) {
throw ArgumentError.value(
cryptoHandshakeTimeout,
'cryptoHandshakeTimeout',
'Must be at least 1 second.',
);
}
quicOptionsBuilder
.setCryptoHandshakeTimeoutSeconds(
cryptoHandshakeTimeout.inSeconds)
?.release();
}There was a problem hiding this comment.
Thanks. A cryptoHandshakeTimeout shorter than one second now throws an ArgumentError, and longer values are rounded down to whole seconds. Both are documented on the parameter and covered by two new integration tests.
6b8dba9 to
c5abfc6
Compare
…tEngine.build CronetEngine.build exposes most DnsOptions, but not preestablishing connections to stale results or the fresh lookup timeout, and it exposes no QuicOptions at all, so 0-RTT, the retry without Alt-Svc on QUIC errors, the handshake timeout and the HTTP/2 session delay cannot be set from Dart. Add preestablishConnectionsToStaleDnsResults and freshLookupTimeout to the DNS options, and enableTlsZeroRtt, retryWithoutAltSvcOnQuicErrors, delayJobsWithAvailableSpdySession and cryptoHandshakeTimeout as QUIC options. The first two DNS options were already bound; the QUIC options come from adding org.chromium.net.QuicOptions to the generated JNI bindings.
c5abfc6 to
ab8eee5
Compare
…cond The Cronet option only takes whole seconds, so a shorter Duration used to become zero. It now throws an ArgumentError, and a longer value is rounded down. Both are documented and covered by integration tests.
Keep both changelog entries and regenerate the JNI bindings with jnigen 1.1.0 so they include QuicOptions on top of upstream regenerated output.
abe3789 to
c274df1
Compare
What this changes
CronetEngine.buildexposes most of Cronet'sDnsOptions, but not two of them, and it exposes noQuicOptions. An app cannot, for example, allow TLS 0-RTT, change the QUIC handshake timeout, or choose how long a stale DNS answer waits for a fresh lookup.New
CronetEngine.buildparameters:preestablishConnectionsToStaleDnsResultsDnsOptions.Builder.preestablishConnectionsToStaleDnsResultsfreshLookupTimeoutStaleDnsOptions.Builder.setFreshLookupTimeoutMillisenableTlsZeroRttQuicOptions.Builder.enableTlsZeroRttretryWithoutAltSvcOnQuicErrorsQuicOptions.Builder.retryWithoutAltSvcOnQuicErrorsdelayJobsWithAvailableSpdySessionQuicOptions.Builder.delayJobsWithAvailableSpdySessioncryptoHandshakeTimeoutQuicOptions.Builder.setCryptoHandshakeTimeoutSeconds(whole seconds)All parameters are nullable and unset by default, so existing callers are unchanged.
The two DNS options were already in the generated bindings. The QUIC options needed
org.chromium.net.QuicOptionsadded totool/jnigen.dartand the bindings regenerated (dart run tool/jnigen.dart).CronetEngine.Builder.setQuicOptionswas already bound.Notes for review
cryptoHandshakeTimeouttakes aDurationand sends whole seconds, which is what the Cronet API accepts. A value is rounded down, and one shorter than a second throws anArgumentErrorinstead of silently becoming zero.1.11.0-wip, and integration tests incronet_engine_test.dart.Testing
dart analyzeis clean forlib/and the example's integration tests.quicOptions(all four options together, a single option, a handshake timeout rounded down, and one under a second rejected) and onednsOptionstest that sets every DNS option at once. They build an engine and make a request against a local server. They need a device or emulator.masteras well (thekotlin-androidplugin is applied on top of AGP 9). The repository's owncronet_httpworkflow is failing onmasterfor the same reason, so the checks here can't pass until that is fixed.