From 10689992cf793bd21873cd2e57e3d3681650b952 Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Wed, 13 Nov 2019 10:25:22 -0500 Subject: [PATCH] Fix an issue with GPU stats not enabled Invoke Surface::enableFrameTimestamps after eglDestroySurface. eglDestroySurface internally disables time stats. Order is important, when CanvasContext::setSurface is invoked with a surface, that is already current (which happens all the time). Test: ran UiBench microbenchmark tests Change-Id: I3d023c3a87da6329c556426d553c744e541b9dff --- libs/hwui/renderthread/CanvasContext.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 826a8ea09d7ee..f0867686c3218 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -147,7 +147,6 @@ void CanvasContext::setSurface(sp&& surface) { mNativeSurface = new ReliableSurface{std::move(surface)}; // TODO: Fix error handling & re-shorten timeout ANativeWindow_setDequeueTimeout(mNativeSurface.get(), 4000_ms); - mNativeSurface->enableFrameTimestamps(true); } else { mNativeSurface = nullptr; } @@ -169,6 +168,10 @@ void CanvasContext::setSurface(sp&& surface) { if (hasSurface) { mHaveNewSurface = true; mSwapHistory.clear(); + // Enable frame stats after the surface has been bound to the appropriate graphics API. + // Order is important when new and old surfaces are the same, because old surface has + // its frame stats disabled automatically. + mNativeSurface->enableFrameTimestamps(true); } else { mRenderThread.removeFrameCallback(this); mGenerationID++;