Allow posting the CronetEngine UI Thread initialization on a custom Ui executor instead of the default Looper.getMainLooper() |
||
Issue descriptionIf CronetEngine is initialized during the Application.onCreate() then the engine will be blocked until the end of the onCreate(). When posting to the Ui Handler, the next available "slot" will always happen after the Application.onCreate(). This means the engine will either be blocked until the onCreate() finished OR the developer must initialize the full CronetEngine on the Ui Thread. By providing a custom Ui Executor, one can initialize the CronetEngine in a background thread and at the same time control when the Ui Thread initialization happens. This is mostly useful if the Application.onCreate() is heavy and long. A simple implementation of the executor could just "collect" these runnables and then "flush" them at a determinate time on the Ui Thread.
,
May 5 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6815aefeae88a9e62065ca8084075e3e98dec267 commit 6815aefeae88a9e62065ca8084075e3e98dec267 Author: pauljensen <pauljensen@chromium.org> Date: Fri May 05 03:00:06 2017 [Cronet] Move initialization to a new thread rather than the UI thread. The UI thread is generally overbooked (esp at app startup time) so avoiding it can greatly improve Cronet startup time. The UI thread was used for initialization previously because it simplified the NetworkChangeNotifierAutoDetect and ProxyChangeListener logic because BroadcastReceiver onReceived callbacks always happen on the UI thread so those classes could be completely single-threaded. This change leaves those classes single-threaded except for their onRecieved() methods which now immediately post to the new initialization thread and check whether their BroadcastReceivers are currently registered. BUG= 709336 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_cronet_tester Review-Url: https://codereview.chromium.org/2812963002 Cr-Commit-Position: refs/heads/master@{#469578} [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/components/cronet/android/cronet_library_loader.cc [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/components/cronet/android/cronet_library_loader.h [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/components/cronet/android/cronet_url_request_context_adapter.cc [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/components/cronet/android/cronet_url_request_context_adapter.h [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/components/cronet/android/java/src/org/chromium/net/impl/CronetLibraryLoader.java [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/net/BUILD.gn [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/net/android/BUILD.gn [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/net/android/java/src/org/chromium/net/ProxyChangeListener.java [add] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/net/android/javatests/src/org/chromium/net/AndroidProxyConfigServiceTestUtil.java [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java [modify] https://crrev.com/6815aefeae88a9e62065ca8084075e3e98dec267/net/proxy/proxy_config_service_android_unittest.cc
,
May 26 2017
Is this fixed now?
,
May 26 2017
,
May 26 2017
Will be available in cronet version 60?
,
May 26 2017
A later fix was needed: crrev.com/472871 The patch and the fix are available in 60.0.3104.0 You can see this by pasting the git commit hash into the "Find Releases" box at https://omahaproxy.appspot.com/ |
||
►
Sign in to add a comment |
||
Comment 1 by pauljensen@chromium.org
, Apr 7 2017Labels: -Cr-Internals-Network-Library Type-Feature