Add display name and id to traces
On a multi-display device, it is helpful to know which display
particular methods are called for. Add information to traces specifying
the name and id of the display. The device still needs to specify
different names for displays (see b/254851304), but the traces will now
show the id, which is helpful until the device is updated, at which
point the names will be immediately helpful.
Output:
- Store a string that combines the readable name and the DisplayId. This
saves allocation costs for the various places where we add this info
to the trace.
- Print the name and id in present and postFramebuffer. Although
postFramebuffer is called by present, future CLs will move it to a
separate thread, and this allows tracking which call applies to which
display.
DisplaySettings:
- Add a field with the display name and id. This allows SkiaRenderEngine
to print them as well.
SkiaRenderEngine:
- Print the name and id in drawLayersInternal
- Replace the outdated text for the function name referring to the class
as "SkiaGL" with a simple call to __func__.
Display:
- Print the name and id in chooseClientCompositionStrategy, which may
also run in another thread.
Bug: 241285473
Test: manual; look at traces
Change-Id: I3081c4e4a7b5874139af6b5dd74a6a8ab0ad8cf7
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index d1daca6..3ee8017 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -29,6 +29,7 @@
#include <compositionengine/impl/OutputLayerCompositionState.h>
#include <compositionengine/impl/planner/Planner.h>
#include <ftl/future.h>
+#include <gui/TraceUtils.h>
#include <thread>
@@ -116,6 +117,9 @@
void Output::setName(const std::string& name) {
mName = name;
+ auto displayIdOpt = getDisplayId();
+ mNamePlusId = base::StringPrintf("%s (%s)", mName.c_str(),
+ displayIdOpt ? to_string(*displayIdOpt).c_str() : "NA");
}
void Output::setCompositionEnabled(bool enabled) {
@@ -427,7 +431,7 @@
}
void Output::present(const compositionengine::CompositionRefreshArgs& refreshArgs) {
- ATRACE_CALL();
+ ATRACE_FORMAT("%s for %s", __func__, mNamePlusId.c_str());
ALOGV(__FUNCTION__);
updateColorProfile(refreshArgs);
@@ -1322,6 +1326,7 @@
const auto& outputState = getState();
renderengine::DisplaySettings clientCompositionDisplay;
+ clientCompositionDisplay.namePlusId = mNamePlusId;
clientCompositionDisplay.physicalDisplay = outputState.framebufferSpace.getContent();
clientCompositionDisplay.clip = outputState.layerStackSpace.getContent();
clientCompositionDisplay.orientation =
@@ -1488,7 +1493,7 @@
}
void Output::postFramebuffer() {
- ATRACE_CALL();
+ ATRACE_FORMAT("%s for %s", __func__, mNamePlusId.c_str());
ALOGV(__FUNCTION__);
if (!getState().isEnabled) {