summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Stoza2015-07-09 14:43:33 -0500
committerDan Stoza2015-07-23 13:15:32 -0500
commit14cd37cf3d7d783eaeb4cfb5f1f9e712d3b49578 (patch)
treec748b48b6b9984358a7137d0775ea09a70934eee /services/surfaceflinger
parent177a4166252afddbe03a5ed7b2e56b0f9173ef81 (diff)
downloadframeworks-native-14cd37cf3d7d783eaeb4cfb5f1f9e712d3b49578.tar.gz
frameworks-native-14cd37cf3d7d783eaeb4cfb5f1f9e712d3b49578.tar.xz
frameworks-native-14cd37cf3d7d783eaeb4cfb5f1f9e712d3b49578.zip
SF: Track missed frames and optionally drop them
Adds code to track whether SurfaceFlinger has sent two frames to HWC in the same vsync window. This can occur if one frame is delayed so far it slips into the next window or just if one frame takes an abnormal amount of time. If this occurs, it shows up as FrameMissed in systrace. Also adds a property debug.sf.drop_missed_frames which, if set, tells SurfaceFlinger to skip sending a frame to HWC (i.e., calling prepare/set) when we detect this condition, which can help prevent backpressure from the HWC implementation. Bug: 22513558 Change-Id: I2df0d44cec5fd6edba419388d8c90b5710d1a5b6
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp34
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h1
2 files changed, 29 insertions, 6 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9b9867d84..01ffac29b 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -163,6 +163,9 @@ SurfaceFlinger::SurfaceFlinger()
163 property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); 163 property_get("ro.bq.gpu_to_cpu_unsupported", value, "0");
164 mGpuToCpuSupported = !atoi(value); 164 mGpuToCpuSupported = !atoi(value);
165 165
166 property_get("debug.sf.drop_missed_frames", value, "0");
167 mDropMissedFrames = atoi(value);
168
166 property_get("debug.sf.showupdates", value, "0"); 169 property_get("debug.sf.showupdates", value, "0");
167 mDebugRegion = atoi(value); 170 mDebugRegion = atoi(value);
168 171
@@ -919,12 +922,31 @@ bool SurfaceFlinger::handleMessageInvalidate() {
919 922
920void SurfaceFlinger::handleMessageRefresh() { 923void SurfaceFlinger::handleMessageRefresh() {
921 ATRACE_CALL(); 924 ATRACE_CALL();
922 preComposition(); 925
923 rebuildLayerStacks(); 926 static nsecs_t previousExpectedPresent = 0;
924 setUpHWComposer(); 927 nsecs_t expectedPresent = mPrimaryDispSync.computeNextRefresh(0);
925 doDebugFlashRegions(); 928 static bool previousFrameMissed = false;
926 doComposition(); 929 bool frameMissed = (expectedPresent == previousExpectedPresent);
927 postComposition(); 930 if (frameMissed != previousFrameMissed) {
931 ATRACE_INT("FrameMissed", static_cast<int>(frameMissed));
932 }
933 previousFrameMissed = frameMissed;
934
935 if (CC_UNLIKELY(mDropMissedFrames && frameMissed)) {
936 // Latch buffers, but don't send anything to HWC, then signal another
937 // wakeup for the next vsync
938 preComposition();
939 repaintEverything();
940 } else {
941 preComposition();
942 rebuildLayerStacks();
943 setUpHWComposer();
944 doDebugFlashRegions();
945 doComposition();
946 postComposition();
947 }
948
949 previousExpectedPresent = mPrimaryDispSync.computeNextRefresh(0);
928} 950}
929 951
930void SurfaceFlinger::doDebugFlashRegions() 952void SurfaceFlinger::doDebugFlashRegions()
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 3759a9240..b3baadd46 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -445,6 +445,7 @@ private:
445 RenderEngine* mRenderEngine; 445 RenderEngine* mRenderEngine;
446 nsecs_t mBootTime; 446 nsecs_t mBootTime;
447 bool mGpuToCpuSupported; 447 bool mGpuToCpuSupported;
448 bool mDropMissedFrames;
448 sp<EventThread> mEventThread; 449 sp<EventThread> mEventThread;
449 sp<EventThread> mSFEventThread; 450 sp<EventThread> mSFEventThread;
450 sp<EventControlThread> mEventControlThread; 451 sp<EventControlThread> mEventControlThread;