From b87c4564313c180a10f96120ec53d481f354b010 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Thu, 17 Jul 2014 19:36:08 +0100 Subject: [PATCH] surfaceflinger: Track the last surfaceview frame for latency dumps When measuring GL latency with dumpsys, it's possible to hit a race condition if the hardware is fast enough to complete rendering the test cycle before the latency dump is requested, since it only matches the latency for live layers (unless it's an animation. See change I8bded1ea08a4cddefef0aa955401052bb9107c90) So always save a reference to the last rendered SurfaceView frame, and dump its values if there isn't an active one. Change-Id: I740e9830161396ea955b5a53322bd8576b5136bc --- services/surfaceflinger/SurfaceFlinger.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 08769c901..165c1b784 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -124,6 +124,8 @@ const String16 sAccessSurfaceFlinger("android.permission.ACCESS_SURFACE_FLINGER" const String16 sReadFramebuffer("android.permission.READ_FRAME_BUFFER"); const String16 sDump("android.permission.DUMP"); +static sp lastSurfaceViewLayer; + // --------------------------------------------------------------------------- SurfaceFlinger::SurfaceFlinger() @@ -1174,6 +1176,10 @@ void SurfaceFlinger::setUpHWComposer() { const sp& layer(currentLayers[i]); layer->setPerFrameData(hw, *cur); setOrientationEventControl(freezeSurfacePresent,id); + if(!strncmp(layer->getName(), "SurfaceView", + 11)) { + lastSurfaceViewLayer = layer; + } } } } @@ -2612,14 +2618,19 @@ void SurfaceFlinger::dumpStatsLocked(const Vector& args, size_t& index if (name.isEmpty()) { mAnimFrameTracker.dumpStats(result); } else { + bool found = false; const LayerVector& currentLayers = mCurrentState.layersSortedByZ; const size_t count = currentLayers.size(); for (size_t i=0 ; i& layer(currentLayers[i]); if (name == layer->getName()) { + found = true; layer->dumpFrameStats(result); } } + if (!found && !strncmp(name.string(), "SurfaceView", 11)) { + lastSurfaceViewLayer->dumpFrameStats(result); + } } }