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:26:00 +0000
commitb123f47bbde4d30be44ca02fc369f6ff83dbff8f (patch)
treee24d17047550b705298480b230e8c1ddb9328601
parenta03e1302db3c51be1e453af179e5549468b501ab (diff)
downloadnative-b123f47bbde4d30be44ca02fc369f6ff83dbff8f.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: I5537c53e8214e2785473839d71fd483d1a3219b6 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 6c9d81ab57..60d246a884 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -610,7 +610,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 e2f77365b3..e89d3a4ce3 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -307,7 +307,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;
virtual status_t getColorManagement(bool* outGetColorManagement) const = 0;
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 960cf1846e..62a1d76360 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -648,7 +648,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;
}
status_t getCompositionPreference(
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 1318bc0b2a..fccaf8166d 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1280,7 +1280,7 @@ LayerDebugInfo Layer::getLayerDebugInfo() const {
LayerDebugInfo info;
const 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 = std::string(getTypeId());
info.mTransparentRegion = ds.activeTransparentRegion_legacy;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 6166789fc4..1a25b8230e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1284,22 +1284,15 @@ 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 {
- // 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 52655944de..03c3d957fd 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -432,7 +432,7 @@ private:
HdrCapabilities* outCapabilities) const override;
status_t enableVSyncInjections(bool enable) override;
status_t injectVSync(nsecs_t when) override;
- status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const override;
+ status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) override;
status_t getColorManagement(bool* outGetColorManagement) const override;
status_t getCompositionPreference(ui::Dataspace* outDataspace, ui::PixelFormat* outPixelFormat,
ui::Dataspace* outWideColorGamutDataspace,