summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/tests/unittests/TransactionSurfaceFrameTest.cpp
AgeCommit message (Collapse)Author
2021-08-09Send releaseCallbackId and releaseFence to correct listenerchaviw
The scenario is the following: 1. Process1 creates a T1 with a new buffer, release callback, and transaction callback. The release callback is stored locally in mReleaseBufferCallbacks so it only lives in Process1. 2. Process2 creates a T2 with a transaction callback 3. When T1 and T2 are merged, the SC from T1 end up getting the transaction callbacks from T2. SC will end up with multiple transaction callbacks 4. In BufferStateLayer, we only added mPreviousReleaseCallbackId to one transaction callback. There's a chance the release callback would only end up on the transaction callback for Process2. Process2 doesn't have the data about the callback since it was only stored in Process1. When Process2 gets the transaction callback, it will not handle the releaseCallbackId since it doesn't know what release callback it represents. Process1 will get a transaction callback, but will not contain a releaseCallbackId. To fix, add releaseBufferEndpoint that is set when the client calls setBuffer. This is used in SurfaceFlinger to recognize which listener was the one that set the buffer so it can send the release information to the correct listener. Test: ReleaseBufferCallback_test Bug: 193565751 Change-Id: I534fbde2a54608c2e30852e48dc0c75c86b22525
2021-06-18Start removing Current stateRobert Carr
Now that we only write to current state from the main thread we can actually just write directly in to drawing state and avoid copying current to drawing state on each frame. simpleperf on bouncing ball indicates this was saving around 8% CPU or so per frame. As a next target we will eliminate the remaining work in doTransaction and eliminate the doTransaction pass. Test: Existing tests pass. simpleperf Bug: 186200583 Change-Id: I59b75747d7371b3ffe870129c8be100c7daa6c4e
2021-06-04SF: Extract virtual display allocation from CEDominik Laskowski
Allocate HAL virtual display and generate HAL/GPU virtual display ID in SF rather than CE. This centralizes the HAL vs. GPU decision as a first step in isolating display configuration (e.g. hotplug, modeset) to be a distinct stage from invalidate/refresh. Rework SF backend hooks for screen capture. Plumb the PhysicalDisplayId to be mirrored by the virtual display to Composer::createVirtualDisplay. This enables the ARC backend to know which display to mirror (instead of making assumptions about the layer stack) or error out if not mirroring (previously done through maybeAllocateDisplayIdForVirtualDisplay), such that SF falls back to creating a GPU virtual display. Bug: 182939859 Bug: 129481165 Test: Enable overlay display and toggle HAL/GPU Test: libsurfaceflinger_unittest Test: libcompositionengine_test Change-Id: I209b245966e544d5ff55d5d118140cfcfa85db15 Merged-In: I209b245966e544d5ff55d5d118140cfcfa85db15
2021-04-16Revert "Revert "Add ExternalTexture class into RenderEngine inte..."Alec Mouri
Revert submission 14199598-revert-14086921-renderengine-external-tex-QJNBWQMQEU Reason for revert: Prepare for relanding Reverted Changes: I01e65a7f4:Revert "Update WaylandRenderSurface to accomodate ... I7d58118c1:Revert "Update Readback VTS to align with RenderEn... I1501890f4:Revert "Add ExternalTexture class into RenderEngin... Added the following fixes: 1. CachedSet renders to intermediate texture variable rather than mTexture directly, since mTexture is not guaranteed to be nonnull. 2. Add null check when setting new buffer in BLAST. Bug: 185524947 Bug: 180767535 Test: builds, boots Test: librenderengine_test Change-Id: I52ea82e24336b496d996bbe3e445db0affe1abb8
2021-04-16Merge "Revert "Add ExternalTexture class into RenderEngine interface"" into ↵Alec Mouri
sc-dev
2021-04-15Revert "Add ExternalTexture class into RenderEngine interface"Alec Mouri
Revert submission 14086921-renderengine-external-tex Reason for revert: Potential culprit for b/185361988 Reverted Changes: I7796764e2:Update WaylandRenderSurface to accomodate interfac... I13904eec4:Update Readback VTS to align with RenderEngine int... I222c71e6e:Add ExternalTexture class into RenderEngine interf... Change-Id: I1501890f4861a3df7ce273f1fe2ccdb275e2632c
2021-04-13Merge "Add ExternalTexture class into RenderEngine interface" into sc-devAlec Mouri
2021-04-13Add ExternalTexture class into RenderEngine interfaceAlec Mouri
ExternalTexture is an RAII structure that wraps raw GraphicBuffers that are passed into RenderEngine. ExternalTexture's role is to help with managing GPU resources of GraphicBuffers by mapping buffers into textures, EGLImages, or AutoBackendTextures depending on the RenderEngine backend. Under the hood, mapExternalTextureBuffer and unmapExternalTextureBuffer (renamed from cacheExternalTextureBuffer and unbindExternalTextureBuffer respectively) are used to help tie resource management to the ExternalTexture lifetime. The main motivation for this is that currently managing buffer lifecycle has historically been errorprone and caused memory leaks, so this improves code health. As part of this: * mapExternalTextureBuffer and unmapExternalTextureBuffer are now protected methods, and are never called outside of RenderEngine with the exception of creating and destroying ExternalTextures. * Because GLESRenderEngine's output buffers are cached differently from Skia RenderEngine, if there are output-only buffers then disable the mapExternalTextureBuffer calls whenever GLESRenderEngine is used. * Custom RAII classes in the Planner and in BufferLayerConsumer are now removed since they're subsumed by ExternalTexture * RenderSurface now controls its own management of ExternalTextures in a small queue * cleanFramebufferCache is now unimplemented for Skia, because ExternalTextures are now deleted whenever a RenderSurface is deleted. Bug: 180767535 Test: libsurfaceflinger_unittest Test: libcompositionengine_test Test: librenderengine_test Test: Simulate virtual displays Test: Screen reotation Test: Movie playback on Google TV Test: Force GPU composition Test: screenshot Change-Id: I222c71e6e1c67485cdeac49e2cb829289af9efec
2021-04-12SurfaceFlinger: Remove deferTransactionUntilRobert Carr
There are no users left Bug: 168505645 Change-Id: I81725bf3c0ef4704e9da25da9a75854b4f172885
2021-03-17Introduce release buffer callback for BufferStateLayerVishnu Nair
Currently BLAST clients use the TransactionCompleted callbacks to determine when to release buffers. The TransactionCompleted callback is overloaded. For transactions without buffers, the callback is called when the transaction is applied on the server. If the Transaction contains one or more buffers, the callback is called when all the buffers are latched and ready to be presented. If we have multiple buffers on multiple transactions, where one or more buffers maybe dropped, the pending callbacks are called together. This may delay signaling the client when a buffer can be released. To fix this, we introduce a new buffer release callback that is called as soon as a buffer is dropped by the server or when a new buffer has been latched and the buffer will no longer be presented. This new callback provides a graphic bufferid to identify the buffer that can be released and a release fence to wait on. BlastBufferQueue has been switched to use this new callback. Other BLAST users continue to use the existing callback. Test: go/wm-smoke Test: atest ReleaseBufferCallbackTest Bug: 178385281 Change-Id: Idd88e4994e543443198a5a8cfa0e3f5f67d5d482
2021-03-11Dropping SurfaceFrames from Drawing StateAdithya Srinivasan
Our assumption is that a buffer committed into drawing state will be latched and presented. Based on this assumption, we present a BufferSurfaceFrame only at latch time instead of commit time. However, during back to back invalidates, there is a chance that the first committed buffer is not latched. It could be replaced by another buffer in the second invalidate. This leads to the SurfaceFrame getting stuck in the pending classification list. To prevent this, have a check in commitTransaction that drops the SurfaceFrame properly if it hasn't been presented before. Back to back invalidate can currently be triggered by just flashing a clean build and launching the dialer. Bug: 182214053 Test: libsurfaceflinger_unittest Change-Id: I6cd9c4cbfb2ca50b96654ed240664758dad86f19
2021-03-10Add isBuffer to SurfaceFrameAdithya Srinivasan
Add a boolean that tells if the SurfaceFrame is representing a buffer or not. This makes it easy to debug lost/stuck frames in the pending classification list. Also add a miniDump for SurfaceFrame to enable debugging the lost frame. Bug: 182214639 Test: Build and flash Change-Id: I6ceef46887a021c2f36e76f37fab8368802465a4
2021-03-01Remove token invalid check for BufferSurfaceFrameAdithya Srinivasan
Since we already check for token invalid cases while attributing jank and tracing, we shouldn't perpetuate this to the creation of SurfaceFrames. Doing so can also result in a case where a buffer is changed but we don't attribute it to a SurfaceFrame. This change makes it so that the State's buffer and BufferSurfaceFrame are tied together and change together. Bug: 179940619 Test: libsurfaceflinger_unittest Change-Id: Id420e5924f162d703adc6831edebf4f100db12de
2021-02-19Merge "Trace predictionExpired and dropped frames properly" into sc-devTreeHugger Robot
2021-02-18Trace predictionExpired and dropped frames properlyAdithya Srinivasan
Allowing frames with prediction expired causes a undesirable skew in the trace. Since the timestamps are zero for this case, the trace packets are also sent out with zero timestamp. These zero timestamps are seen as the earliest possible time in a trace and hence make it look like the trace contains 1000s of seconds of data while it actually doesn't. This change addresses this issue by making SurfaceFrames not send any expected timeline packets if prediction is expired. For actual timeline packets, we apply a delta to the end time so that it looks like the frame has a start and an end. For dropped SurfaceFrames, we don't have an actual end time so far. This change adds a dropTime to the SurfaceFrame so that we can keep track of it in trace and dumpsys. Bug: 179905685 Test: libsurfaceflinger_unittest:FrameTimelineTest Change-Id: I573037be27f8a74670a65cad791841fa6ed75e20
2021-02-12Return janktype properly for dropped framesAdithya Srinivasan
In SurfaceFrame::getJankType(), a dropped frame won't have any present time set and will return std::nullopt currently. This behavior can result in a memory leak in releasePendingBuffer. Whenever SurfaceFrames are created, they are added to a deque 'mPendingJankClassification'. This deque is popped from the front as and when the frames are presented. However, if a dropped frame is in the front of the deque, the deque keeps growing in size to infinity. Since getJankType() reports a std::nullopt, it assumes that the frame hasn't been presented yet and keeps waiting for it. Bug: 179701581 Test: libsurfaceflinger_unittest Change-Id: I8ad1ed07222d39e4f98e4f7f3178db9fe52ea712
2021-02-04Fix Transaction tracking for FrameTimelineAdithya Srinivasan
The current setup only supports one SurfaceFrame per DrawingState for Transactions. This becomes problematic if more than one Transaction is submitted for the same vsync, on the same layer. On top of this, the Blast transactions can have a buffer that could result in a buffer drop. This change adds the support to hold multiple SurfaceFrames in the Layer's State. It also adds a bufferSurfaceFrame that's intended only for Blast Transactions with a Buffer. All other Transactions are tracked in the bufferlessSurfaceFrames. Additionally, this change also adds a lastLatchTime. It is needed for classifying BufferStuffing properly. Bug: 176106798 Test: open any app from the launcher and at the same time check dumpsys Change-Id: Id3b8369ca206f8b89be3041e5fc018f1f1be1d23 Merged-In: Id3b8369ca206f8b89be3041e5fc018f1f1be1d23