SF: non blocking createSurface
The createSurface would add the created layer into current state, which
would hold the state lock and may block the binder thread while the main
thread is holding the same lock.
This CL uses a transaction to perform the behaviors of adding the
created layer into current state, so we could return the created layer
without holding the lock and do other stuff in the main thread.
Also make some test cases to perform a sync transaction after calling
createSurface, that could make sure we have done the layer creation.
Bug: 179647628
Test: atest libsurfaceflinger_unittest
Test: atest SurfaceFlinger_test
Test: libgui_test
Test: SurfaceControlTest
Change-Id: I394b74e9c1cc675df4cacd38ab5da24f0492289d
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 751b95a..5933e1c 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -102,14 +102,13 @@
// test flakiness.
mSurfaceControl = mComposerClient->createSurface(
String8("Test Surface"), 32, 32, PIXEL_FORMAT_RGBA_8888, 0);
+ SurfaceComposerClient::Transaction().apply(true);
ASSERT_TRUE(mSurfaceControl != nullptr);
ASSERT_TRUE(mSurfaceControl->isValid());
Transaction t;
- ASSERT_EQ(NO_ERROR, t.setLayer(mSurfaceControl, 0x7fffffff)
- .show(mSurfaceControl)
- .apply());
+ ASSERT_EQ(NO_ERROR, t.setLayer(mSurfaceControl, 0x7fffffff).show(mSurfaceControl).apply());
mSurface = mSurfaceControl->getSurface();
ASSERT_TRUE(mSurface != nullptr);