SF: Avoid updating clients with stale or incorrect transform hints
When the layer is removed from a display or the display the layer is on
is turned off, the client will continue to receive transform hint
updates via the transaction complete callback using the default/active
displays install orientation. Once the layer is back on the display and
it does not submit a new frame, a buffer with a suboptimal transform
may remain on display.
Fix this by not reporting stale/incorrect values via the callback. Once
the layer is reparent back to the display and the display state is not
OFF, it will continue to get hints via the callback.
For special cases where we want the app to draw its first frame before
the display is available, we rely on WMS and DMS to provide the right
information so the client can calculate the hint.
Bug: 251360251
Test: move app between displays, rotate, check final buffer transforms
Change-Id: I0a9abac7e9cf4ade1c49ec400e73b634c8269b4b
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 81b4d3d..a957059 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -385,10 +385,11 @@
surfaceStats.previousReleaseFence, surfaceStats.transformHint,
surfaceStats.eventStats,
surfaceStats.currentMaxAcquiredBufferCount);
- if (callbacksMap[callbackId].surfaceControls[surfaceStats.surfaceControl]) {
+ if (callbacksMap[callbackId].surfaceControls[surfaceStats.surfaceControl] &&
+ surfaceStats.transformHint.has_value()) {
callbacksMap[callbackId]
.surfaceControls[surfaceStats.surfaceControl]
- ->setTransformHint(surfaceStats.transformHint);
+ ->setTransformHint(*surfaceStats.transformHint);
}
// If there is buffer id set, we look up any pending client release buffer callbacks
// and call them. This is a performance optimization when we have a transaction