Save Layer instead of Handle to LayerCreatedState
Saving Handle to LayerCreatedState can lead to the destruction of Handle
when handleLayerCreatedLocked returns if the client side releases the
Handle before that. That destruction will attempt to acquire mStateLock
in the main thread again and lead to a deadlock.
Not saving Handle to LayerCreatedState will avoid Handle being destroyed
in the main thread. The destruction of Layer in the main thread is OK.
To make that happen I moved the final resolution of addToRoot to
createLayer as well because the treatments for invalid parentHandle
and invalid parentLayer are different.
Bug: 204204635
Bug: 202621651
Test: atest SurfaceFlinger_test
Test: atest libsurfaceflinger_unittest
Change-Id: I0854203c0949302d7f514d34b956eb7ae976c51f
2 files changed