Two of Cronet NQE Tests are flaky |
|||||
Issue description
There is a race condition in the NQETest#testPrefsWriteRead & NQETest#testQuicDisabled tests. Namely, the main thread is trying to execute the native method ConfigureNetworkQualityEstimatorForTesting while the Cronet initialization thread is trying to execute the native InitRequestContextOnInitThread method. If due to the CPU scheduling the initialization thread completes all tasks before the ConfigureNetworkQualityEstimatorForTesting method posts to the network thread, the tests will fail.
In order to reproduce the issue, it is enough to introduce a small delay in the CronetURLRequestContextAdapter::ConfigureNetworkQualityEstimatorForTesting(...) method before it posts to the network thread. Here is the diff:
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -547,6 +547,7 @@ void CronetURLRequestContextAdapter::ConfigureNetworkQualityEstimatorForTesting(
jboolean use_local_host_requests,
jboolean use_smaller_responses,
jboolean disable_offline_check) {
+ sleep(3);
PostTaskToNetworkThread(
FROM_HERE,
base::Bind(&CronetURLRequestContextAdapter::
,
Aug 24 2017
Oops...wrong bug. :)
,
Aug 28 2017
,
Aug 28 2017
,
Apr 10 2018
Issue 831213 has been merged into this issue.
,
Aug 17
I confirm this test fails sometimes: https://ci.chromium.org/buildbot/chromium.android/Android%20Cronet%20Builder%20%28dbg%29/9924 It appeared today in the 'Tree closers' section. https://sheriff-o-matic.appspot.com/android. It is flaky, so it will probably be gone in the next build.
,
Sep 13
Looks like this hasn't failed again in the past 100 builds. https://ci.chromium.org/buildbot/chromium.android/Android%20Cronet%20Builder%20%28dbg%29/?limit=100 |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by kapishnikov@chromium.org
, Aug 23 2017We don't see the failures often because the InitializeOnNetworkThread() method posts the execution of InitializeNQEPrefsOnNetworkThread() to the network thread (same thread). This significantly increases the chance of ConfigureNetworkQualityEstimatorOnNetworkThreadForTesting() executing first. It should not be necessary to post tasks from networks thread to the same thread during the initialization. network_qualities_prefs_manager_ = base::MakeUnique<net::NetworkQualitiesPrefsManager>( base::MakeUnique<NetworkQualitiesPrefDelegateImpl>( pref_service_.get())); PostTaskToNetworkThread(FROM_HERE, base::Bind(&CronetURLRequestContextAdapter:: InitializeNQEPrefsOnNetworkThread, base::Unretained(this)));