SF: Move screenshot Surface ops off main thread
This change rearranges the various operations that correspond to capturing a screenshot such that all of the Surface-related ones (connect, dequeue, queue, disconnect) are performed on the incoming Binder thread rather than on SurfaceFlinger's main thread. This has two major benefits: 1) It reduces the amount of time that the SurfaceFlinger main thread is blocked while performing a screenshot, often by a considerable amount. This should reduce the risk of jank when screenshots are taken, such as for task snapshots during window transitions. 2) It means that the SurfaceFlinger main thread is not susceptible to being blocked by a badly-performing BufferQueue consumer. This also enables us to remove the GraphicProducerWrapper class, which was previously performing a similar role. Finally, this change also adds a mechanism that detects if the screenshot would have been performed between the two phases of normal SurfaceFlinger operation (invalidate and refresh), and defers it if this condition is detected. This should further reduce the risk of jank as a screenshot will only occur between frames rather than in the middle of a frame. Bug: 62257775 Test: SurfaceFlinger_test and manual verification that screenshots still work Change-Id: I23e6f088b4d6e477472dfc2a6c36ef3dd930c047
Loading
Please register or sign in to comment