widi: Fix gaps in VirtualDevice fence use and add safety check
BZ: 200647
The patch "Support secure video playback with VSP composition" didn't
check all acquire fences that could be set by SurfaceFlinger in each
case, so it was possible that some fences were set and we didn't sync
on them or close them. Therefore fences wouldn't be freed and we would
hit the file descriptor limit. This can cause the failure of any
operation that allocates a file descriptor.
There were also error conditions where we wouldn't close the acquire
fences that we normally would handle, again causing an fd leak. In
these error cases we also wouldn't signal the release/retire fences
that we create and give back to SurfaceFlinger, which would lead to
hangs and fence timeouts.
This patch adds the missing fence checking, and ensures that error
paths will still close acquire fences and signal release fence. Return
value checking for sync_wait() and close() is added to make sure
errors such as closing an already closed fence will be detected and
logged. Also, before returning from commit(), we check if we failed to
handle any of the acquire fences, and log a warning and close it in
that case.
A corner case with composition before scaledWidth/scaledHeight are set
in the Intel WiDi path caused us to fall back to color conversion, set
up fences again and leak the first set of fences. This is fixed by not
triggering the fallback.
Also, we now set a release fence fd on the target framebuffer (the
source buffer for color conversion) when in clone mode, which was
missing before. Before we just provided a retire fence for outbuf.
Change-Id: I0beb6a5683550b1db4ef61dba1eae6db89902368
Signed-off-by: Brian Rogers <brian.e.rogers@intel.com>
diff --git a/include/VirtualDevice.h b/include/VirtualDevice.h
index 16474b8..cdbdcc4 100644
--- a/include/VirtualDevice.h
+++ b/include/VirtualDevice.h
@@ -115,6 +115,7 @@
// fence info
int mSyncTimelineFd;
unsigned mNextSyncPoint;
+ bool mExpectAcquireFences;
// async blit info
DECLARE_THREAD(WidiBlitThread, VirtualDevice);