Non-visible layers are now "inactive"
When setting "explicit_refresh_rate_hints", we saw the perfetto trace is
very noisy in LayerHistory/RefreshRateSelector. This change fixes this
in a few ways:
- Non-visible layers should now be inactive in LayerHistory. This should
be safe because non-visible layers were treated as NoVote,
and does not affect the refresh rate chosen.
- LayerInfo for ExplicitCategory now considers NoVote (from non-visible
layer).
- RefreshRateSelector::calculateLayerScoreLocked does not have any
interesting trace calls itself, so remove its ATRACE_CALL.
Bug: 305008279
Test: atest libsurfaceflinger_unittest
Test: atest SetFrameRateTest
Test: perfetto trace not noisy
Change-Id: I40056ea48b8323b7be0936e7717706bf9a0926f9
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp
index 069d89b..ff82914 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.cpp
+++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp
@@ -21,6 +21,7 @@
#include "LayerHistory.h"
#include <android-base/stringprintf.h>
+#include <com_android_graphics_surfaceflinger_flags.h>
#include <cutils/properties.h>
#include <gui/TraceUtils.h>
#include <utils/Log.h>
@@ -39,8 +40,14 @@
namespace {
+using namespace com::android::graphics::surfaceflinger;
+
bool isLayerActive(const LayerInfo& info, nsecs_t threshold) {
- // Layers with an explicit frame rate or frame rate category are always kept active,
+ if (flags::misc1() && !info.isVisible()) {
+ return false;
+ }
+
+ // Layers with an explicit frame rate or frame rate category are kept active,
// but ignore NoVote.
if (info.getSetFrameRateVote().isValid() && !info.getSetFrameRateVote().isNoVote()) {
return true;