Preload chrome split on startup
The chrome split can take a long time to load, so we get significant improvements in startup time if this work is offloaded to a background thread. Ideally, we would give as much time as possible to allow this preload to finish, which means running as much code as possible which does not depend on the chrome split during the preload. This required refactoring much of attachBaseContext into the base module, and moving the pieces which could not be easily moved to the base module into onCreate. The order of startup generally goes: 1. Application.attachBaseContext 2. Each provider is instantiated in order, and onCreate is called 3. Application.onCreate If a provider lives in a split, it will call createContextForSplit on the application. This will end up being the first thing needing the chrome split, which will wait for the preload to complete. This is why ChromeFileProvider was moved to the base module, so there could be more time to preload. Pinpoint runs: Pixel 2: https://pinpoint-dot-chromeperf.appspot.com/job/16925180d20000 -7% messageloop_start_time -3% first_contentful_paint_time -3.8% navigation_commit_time Android Go: https://pinpoint-dot-chromeperf.appspot.com/job/115e53e7520000 -18.7% messageloop_start_time -1.5% first_contentful_paint_time -2.1% navigation_commit_time A couple notes: - setUsageAndCrashReportingFromNative was removed from UmaUtils because it is never used, and allowed for much more easily bringing UmaUtils into the base module. - I wanted to make sure PureJavaExceptionHandler is still set up as early as possible, so left it in attachBaseContext. This required loading PureJavaExceptionReporter by reflection if an exception happens, since it has many hooks into chrome code. - MainDexApplicationImpl is no longer needed since all the common code was moved to SplitCompatApplication Bug: 1150600 Change-Id: Idd6c11293e47fa5e8bd6eb30c14535e60c204867 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2570125 Commit-Queue: Clark DuVall <cduvall@chromium.org> Reviewed-by:Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/master@{#833923}
Showing
This diff is collapsed.
Please register or sign in to comment