SF: Fix jank after folding due to power sequence
SF assumed that DM always powers off the active display before powering
on the other display. However, this is not the case when simultaneously
folding and pressing the power button to turn on the rear display.
SF then behaves as if all displays were off (e.g. synthetic VSYNC, low
thread priority), causing consistent jank until the next power or fold
event. Fix this by activating the other display if already powered on.
Fixes: 294230902
Test: No jank after simultaneously folding and hitting the power button.
Test: FoldableTest.promotesPacesetterOnConcurrentPowerOff
Change-Id: I5d0bdafc4002ce5ae86866f457132f8a0f178698
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index db1c342..ee1e1f6 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -934,7 +934,8 @@
template <typename Predicate>
sp<DisplayDevice> findDisplay(Predicate p) const REQUIRES(mStateLock) {
const auto it = std::find_if(mDisplays.begin(), mDisplays.end(),
- [&](const auto& pair) { return p(*pair.second); });
+ [&](const auto& pair)
+ REQUIRES(mStateLock) { return p(*pair.second); });
return it == mDisplays.end() ? nullptr : it->second;
}
@@ -1047,6 +1048,9 @@
VirtualDisplayId acquireVirtualDisplay(ui::Size, ui::PixelFormat) REQUIRES(mStateLock);
void releaseVirtualDisplay(VirtualDisplayId);
+ // Returns a display other than `mActiveDisplayId` that can be activated, if any.
+ sp<DisplayDevice> getActivatableDisplay() const REQUIRES(mStateLock, kMainThreadContext);
+
void onActiveDisplayChangedLocked(const DisplayDevice* inactiveDisplayPtr,
const DisplayDevice& activeDisplay)
REQUIRES(mStateLock, kMainThreadContext);