Remove calls to invokeOnCompletion
This CL removes all calls to invokeOnCompletion in STL codebase. As
mentioned in the KDoc, there is no guarantee on which thread the
invokeOnCompletion block is run, which can cause concurrency issues that
throw an exception since ag/27342795.
The calls to invokeOnCompletion were replaced by a try/finally block.
However, it is important to note that a try block launched inside a
coroutine might never run if the coroutine is cancelled before it
starts. For this reason, we must also specify `start = ATOMIC` when
launching the coroutine to make sure that the try/finally block will
definitely run until the first suspension point.
Bug: 290930950
Bug: 340824084
Test: atest PlatformComposeSceneTransitionLayoutTests
Flag: com.android.systemui.scene_container
Change-Id: Ia822d4a2e0f424cd7a6715fb7dbeaf46affcaba3
3 files changed