Don't launch a coroutine job if no jobs to cancel

Flag: com.android.launcher3.enable_coroutine_threading_improvements
Bug: 417598777
Test: Presubmits
Change-Id: I474e3e12faf2886b593571e9625a1d16df742c0d
This commit is contained in:
Uwais Ashraf
2025-05-23 10:50:38 +00:00
parent 5ae4fb14f4
commit 7d640afaba
@@ -952,7 +952,9 @@ constructor(
// onAttach or another moment in the lifecycle.
val coroutineJobsToCancel = coroutineJobs.toList()
coroutineJobs.clear()
if (enableCoroutineThreadingImprovements() && coroutineJobsToCancel.isNotEmpty()) {
if (coroutineJobsToCancel.isEmpty()) return
if (enableCoroutineThreadingImprovements()) {
// TODO(b/391842220): This should ideally be handled in the completion block of the
// jobs above to be cancelled.
taskContainers.forEach {