Skip to content

Commit

Permalink
surfaceflinger: Track the last surfaceview frame for latency dumps
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rmcc committed Jul 17, 2014
1 parent 04b8813 commit d7df45b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions services/surfaceflinger/SurfaceFlinger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,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<Layer> lastSurfaceViewLayer;

// ---------------------------------------------------------------------------

SurfaceFlinger::SurfaceFlinger()
Expand Down Expand Up @@ -1211,6 +1213,10 @@ void SurfaceFlinger::setUpHWComposer() {
uint32_t(draw[i].orientation));
}
}
if(!strncmp(layer->getName(), "SurfaceView",
11)) {
lastSurfaceViewLayer = layer;
}
}
}
}
Expand Down Expand Up @@ -2745,14 +2751,19 @@ void SurfaceFlinger::dumpStatsLocked(const Vector<String16>& args, size_t& index
if (name.isEmpty()) {
mAnimFrameTracker.dump(result);
} else {
bool found = false;
const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
const size_t count = currentLayers.size();
for (size_t i=0 ; i<count ; i++) {
const sp<Layer>& layer(currentLayers[i]);
if (name == layer->getName()) {
found = true;
layer->dumpStats(result);
}
}
if (!found && !strncmp(name.string(), "SurfaceView", 11)) {
lastSurfaceViewLayer->dumpStats(result);
}
}
}

Expand Down

0 comments on commit d7df45b

Please sign in to comment.