diff options
author | Keun-young Park <keunyoung@google.com> | 2017-05-19 17:13:04 -0700 |
---|---|---|
committer | Keun-young Park <keunyoung@google.com> | 2017-05-23 09:34:24 -0700 |
commit | 721c9dc1253db9a713063674d196d57b83536d6a (patch) | |
tree | 6188bdbd9a8a5efe4f4163f31f2250582de08797 /cmds/bootanimation/bootanimation_main.cpp | |
parent | 1ba237d237830bf97b97b1cf1d7bd205b2c4fc90 (diff) |
reduce flunctuation in boot animation start / stopping time
- Add separate 100ms interval polling for SurfaceFlinger. Otherwise,
it can be blocked with 1 sec polling and cause 1 sec of additional
delay frequently.
bug: 38450031
bug: 35253872
Test: many reboots and check time to finish boot animation, python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 100 -f -e 15 -w 30 -v
Change-Id: I353ca04183cbe59b82da99dc3fecfce63314cd2f
Diffstat (limited to 'cmds/bootanimation/bootanimation_main.cpp')
-rw-r--r-- | cmds/bootanimation/bootanimation_main.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cmds/bootanimation/bootanimation_main.cpp b/cmds/bootanimation/bootanimation_main.cpp index dca7ea6daa3e..3689d5ed937e 100644 --- a/cmds/bootanimation/bootanimation_main.cpp +++ b/cmds/bootanimation/bootanimation_main.cpp @@ -16,12 +16,16 @@ #define LOG_TAG "BootAnimation" +#include <stdint.h> +#include <inttypes.h> + #include <binder/IPCThreadState.h> #include <binder/ProcessState.h> #include <binder/IServiceManager.h> #include <cutils/properties.h> #include <sys/resource.h> #include <utils/Log.h> +#include <utils/SystemClock.h> #include <utils/threads.h> #include "BootAnimation.h" @@ -47,6 +51,26 @@ int main() sp<ProcessState> proc(ProcessState::self()); ProcessState::self()->startThreadPool(); + // TODO: replace this with better waiting logic in future, b/35253872 + int64_t waitStartTime = elapsedRealtime(); + sp<IServiceManager> sm = defaultServiceManager(); + const String16 name("SurfaceFlinger"); + const int SERVICE_WAIT_SLEEP_MS = 100; + const int LOG_PER_RETRIES = 10; + int retry = 0; + while (sm->checkService(name) == nullptr) { + retry++; + if ((retry % LOG_PER_RETRIES) == 0) { + ALOGW("Waiting for SurfaceFlinger, waited for %" PRId64 " ms", + elapsedRealtime() - waitStartTime); + } + usleep(SERVICE_WAIT_SLEEP_MS * 1000); + }; + int64_t totalWaited = elapsedRealtime() - waitStartTime; + if (totalWaited > SERVICE_WAIT_SLEEP_MS) { + ALOGI("Waiting for SurfaceFlinger took %" PRId64 " ms", totalWaited); + } + // create the boot animation object sp<BootAnimation> boot = new BootAnimation(); |