diff options
| author | 2020-01-07 19:53:56 -0800 | |
|---|---|---|
| committer | 2020-01-08 10:50:35 -0800 | |
| commit | d381938b704b640dd58fbd0c2879617e6e3e512a (patch) | |
| tree | d8243440b9f3d0b63940eb8e18bd96bc7260711c /libs/graphicsenv/GraphicsEnv.cpp | |
| parent | 0ecfc27cf8a847087b8ee0edef6ad52be03e9129 (diff) | |
GpuStats: tighten the triggers to send GPU stats to gpuservice
Before:
(1) Any driver gets loaded and GraphicsEnvironment setup
(2) At least one activity launched and GraphicsEnvironment setup
(3) Target stats collected
After:
General pre-condition: at least one activity has been launched and
GraphicsEnvironment setup is not skipped.
(1) Any driver gets loaded
(2) At least one activity launched
(3) Target stats collected
Test: adb shell dumpsys gpu
Change-Id: Iba714e6c98d90bf9a21abdbdc2067e834a306cc2
Diffstat (limited to 'libs/graphicsenv/GraphicsEnv.cpp')
| -rw-r--r-- | libs/graphicsenv/GraphicsEnv.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp index 354703b9e4..f07c23132d 100644 --- a/libs/graphicsenv/GraphicsEnv.cpp +++ b/libs/graphicsenv/GraphicsEnv.cpp @@ -145,6 +145,12 @@ void GraphicsEnv::setDriverPathAndSphalLibraries(const std::string path, void GraphicsEnv::hintActivityLaunch() { ATRACE_CALL(); + { + std::lock_guard<std::mutex> lock(mStatsLock); + if (mActivityLaunched) return; + mActivityLaunched = true; + } + std::thread trySendGpuStatsThread([this]() { // If there's already graphics driver preloaded in the process, just send // the stats info to GpuStats directly through async binder. @@ -228,12 +234,11 @@ void GraphicsEnv::setDriverLoaded(GpuStatsInfo::Api api, bool isDriverLoaded, ATRACE_CALL(); std::lock_guard<std::mutex> lock(mStatsLock); - const bool doNotSend = mGpuStats.appPackageName.empty(); if (api == GpuStatsInfo::Api::API_GL) { - if (doNotSend) mGpuStats.glDriverToSend = true; + mGpuStats.glDriverToSend = true; mGpuStats.glDriverLoadingTime = driverLoadingTime; } else { - if (doNotSend) mGpuStats.vkDriverToSend = true; + mGpuStats.vkDriverToSend = true; mGpuStats.vkDriverLoadingTime = driverLoadingTime; } @@ -250,10 +255,18 @@ static sp<IGpuService> getGpuService() { return interface_cast<IGpuService>(binder); } +bool GraphicsEnv::readyToSendGpuStatsLocked() { + // Only send stats for processes having at least one activity launched and that process doesn't + // skip the GraphicsEnvironment setup. + return mActivityLaunched && !mGpuStats.appPackageName.empty(); +} + void GraphicsEnv::setTargetStats(const GpuStatsInfo::Stats stats, const uint64_t value) { ATRACE_CALL(); std::lock_guard<std::mutex> lock(mStatsLock); + if (!readyToSendGpuStatsLocked()) return; + const sp<IGpuService> gpuService = getGpuService(); if (gpuService) { gpuService->setTargetStats(mGpuStats.appPackageName, mGpuStats.driverVersionCode, stats, @@ -265,8 +278,7 @@ void GraphicsEnv::sendGpuStatsLocked(GpuStatsInfo::Api api, bool isDriverLoaded, int64_t driverLoadingTime) { ATRACE_CALL(); - // Do not sendGpuStats for those skipping the GraphicsEnvironment setup - if (mGpuStats.appPackageName.empty()) return; + if (!readyToSendGpuStatsLocked()) return; ALOGV("sendGpuStats:\n" "\tdriverPackageName[%s]\n" |