summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishnu Nair <vishnun@google.com>2020-06-22 11:52:39 -0700
committerVishnu Nair <vishnun@google.com>2020-06-23 18:32:02 +0000
commit927b3b120839954a575b4e8c498b1b4d4d375afa (patch)
tree8023aefd1eb30618560a98966adf46173f79d6b8
parent09c9a55bb6ce62194c93068c761c72e582ca3d03 (diff)
downloadnative-927b3b120839954a575b4e8c498b1b4d4d375afa.tar.gz
Call Layer::getLayerDebugInfo from the main thread
Fixes an issue where drawing state could be accessed from a binder thread. The function also mixed current state with drawing state incorrectly. The function now only retrieves drawing state. Bug: 150226608 Test: Steps in bug doesn't repro Test: atest sffakehwc_test Merged-In: I04daedcb9a890083cc710bab30b295e14b9872ae Change-Id: I04daedcb9a890083cc710bab30b295e14b9872ae
-rw-r--r--libs/gui/ISurfaceComposer.cpp2
-rw-r--r--libs/gui/include/gui/ISurfaceComposer.h2
-rw-r--r--libs/gui/tests/Surface_test.cpp2
-rw-r--r--services/surfaceflinger/Layer.cpp2
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp19
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h2
6 files changed, 11 insertions, 18 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index cec86e2a04..fdf56e6e01 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -537,7 +537,7 @@ public:
return result;
}
- virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
+ virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers)
{
if (!outLayers) {
return UNEXPECTED_NULL;
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 0db21a56e3..9d1f3b0055 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -228,7 +228,7 @@ public:
*
* Requires the ACCESS_SURFACE_FLINGER permission.
*/
- virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const = 0;
+ virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 04686e5ad2..2b4c9019be 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -625,7 +625,7 @@ public:
return NO_ERROR;
}
status_t injectVSync(nsecs_t /*when*/) override { return NO_ERROR; }
- status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* /*layers*/) const override {
+ status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* /*layers*/) override {
return NO_ERROR;
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index a062aa1fad..8fd1ce1b60 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1424,7 +1424,7 @@ LayerDebugInfo Layer::getLayerDebugInfo() const {
LayerDebugInfo info;
const Layer::State& ds = getDrawingState();
info.mName = getName();
- sp<Layer> parent = getParent();
+ sp<Layer> parent = mDrawingParent.promote();
info.mParentName = (parent == nullptr ? std::string("none") : parent->getName().string());
info.mType = String8(getTypeId());
info.mTransparentRegion = ds.activeTransparentRegion;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2c7f8c4c1d..efccaaa8df 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1252,7 +1252,7 @@ status_t SurfaceFlinger::injectVSync(nsecs_t when) {
return NO_ERROR;
}
-status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
+status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers)
NO_THREAD_SAFETY_ANALYSIS {
IPCThreadState* ipc = IPCThreadState::self();
const int pid = ipc->getCallingPid();
@@ -1263,20 +1263,13 @@ status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayer
return PERMISSION_DENIED;
}
- // Try to acquire a lock for 1s, fail gracefully
- const status_t err = mStateLock.timedLock(s2ns(1));
- const bool locked = (err == NO_ERROR);
- if (!locked) {
- ALOGE("LayerDebugInfo: SurfaceFlinger unresponsive (%s [%d]) - exit", strerror(-err), err);
- return TIMED_OUT;
- }
-
outLayers->clear();
- mCurrentState.traverseInZOrder([&](Layer* layer) {
- outLayers->push_back(layer->getLayerDebugInfo());
- });
+ postMessageSync(new LambdaMessage([&]() {
+ mDrawingState.traverseInZOrder([&](Layer* layer) {
+ outLayers->push_back(layer->getLayerDebugInfo());
+ });
- mStateLock.unlock();
+ }));
return NO_ERROR;
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 1f8c205466..d14e13d8b8 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -452,7 +452,7 @@ private:
HdrCapabilities* outCapabilities) const;
virtual status_t enableVSyncInjections(bool enable);
virtual status_t injectVSync(nsecs_t when);
- virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const;
+ virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers);
/* ------------------------------------------------------------------------