SurfaceFlinger: clear LayerHistory on first touch
- Restructure the code in RefreshRateConfigs to be able to clear
LayerHistory frames on the first touch event. Without this change we
clear the history on every frame as long as the touch timer hasn't
expired.
- Add log prints for debugging
Test: Play 24fps video in YouTube PIP mode and rotate the device - no jank
Test: Chrome playing video - no refresh rate switching
Test: Hide/Show keyboard when inputting text
Test: Running Hay Day and observing refresh rate
Bug: 157096772
Change-Id: I7cabecd6ea27ec335e773aa22bb111fa8ec89195
diff --git a/services/surfaceflinger/Scheduler/LayerHistoryV2.cpp b/services/surfaceflinger/Scheduler/LayerHistoryV2.cpp
index 359fe1b..67edef4 100644
--- a/services/surfaceflinger/Scheduler/LayerHistoryV2.cpp
+++ b/services/surfaceflinger/Scheduler/LayerHistoryV2.cpp
@@ -62,13 +62,17 @@
const auto layer = weak.promote();
if (!layer) return;
- const auto& name = layer->getName();
- const auto noVoteTag = "LFPS NoVote " + name;
- const auto heuristicVoteTag = "LFPS Heuristic " + name;
- const auto explicitDefaultVoteTag = "LFPS ExplicitDefault" + name;
- const auto explicitExactOrMultipleVoteTag = "LFPS ExplicitExactOrMultiple" + name;
- const auto minVoteTag = "LFPS Min " + name;
- const auto maxVoteTag = "LFPS Max " + name;
+ const auto makeTag = [layer](LayerHistory::LayerVoteType vote) {
+ return "LFPS " + RefreshRateConfigs::layerVoteTypeString(vote) + " " + layer->getName();
+ };
+
+ const auto noVoteTag = makeTag(LayerHistory::LayerVoteType::NoVote);
+ const auto heuristicVoteTag = makeTag(LayerHistory::LayerVoteType::Heuristic);
+ const auto explicitDefaultVoteTag = makeTag(LayerHistory::LayerVoteType::ExplicitDefault);
+ const auto explicitExactOrMultipleVoteTag =
+ makeTag(LayerHistory::LayerVoteType::ExplicitExactOrMultiple);
+ const auto minVoteTag = makeTag(LayerHistory::LayerVoteType::Min);
+ const auto maxVoteTag = makeTag(LayerHistory::LayerVoteType::Max);
ATRACE_INT(noVoteTag.c_str(), type == LayerHistory::LayerVoteType::NoVote ? 1 : 0);
ATRACE_INT(heuristicVoteTag.c_str(), type == LayerHistory::LayerVoteType::Heuristic ? fps : 0);
@@ -79,7 +83,7 @@
ATRACE_INT(minVoteTag.c_str(), type == LayerHistory::LayerVoteType::Min ? 1 : 0);
ATRACE_INT(maxVoteTag.c_str(), type == LayerHistory::LayerVoteType::Max ? 1 : 0);
- ALOGD("%s: %s @ %d Hz", __FUNCTION__, name.c_str(), fps);
+ ALOGD("%s: %s @ %d Hz", __FUNCTION__, layer->getName().c_str(), fps);
}
} // namespace
@@ -90,7 +94,7 @@
void LayerHistoryV2::registerLayer(Layer* layer, float /*lowRefreshRate*/, float highRefreshRate,
LayerVoteType type) {
const nsecs_t highRefreshRatePeriod = static_cast<nsecs_t>(1e9f / highRefreshRate);
- auto info = std::make_unique<LayerInfoV2>(highRefreshRatePeriod, type);
+ auto info = std::make_unique<LayerInfoV2>(layer->getName(), highRefreshRatePeriod, type);
std::lock_guard lock(mLock);
mLayerInfos.emplace_back(layer, std::move(info));
}