Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 929a9d1f authored by Ats Jenk's avatar Ats Jenk
Browse files

Initialize bubble expanded view on shell main thread

Move bubble expanded view initialization from background thread to main
thread.
Expanded view initialization updates the view hierarchy by adding the
bubble TaskView to the expanded view container. If the TaskView is
already added to a container, it is removed from the previous container.

This fixes a bug related to bubble view inflation. Previously it was
possible for a TaskView to be removed from bubble expanded view
container if the expanded view is inflated and initialized twice. The
second initialization removes the TaskView from the first container. But
we only keep using the first container. Which results in an expanded view
with no TaskView set.

The following order of events had to occur for this bug to manifest.
Bubble gets inflated with TASK1. TASK1 starts and inflates and
initializes expanded view on background thread. TASK1 schedules work on
the main thread to update the bubble and set it to inflated state.
An update to bubble comes in, since main thread work is still pending,
we see that the bubble is not inflated. TASK2 is created to inflate the
bubble. TASK2 starts and inflates and initializes expanded view on
background thread. TASK2 will not recreate the TaskView, but reuses the
existing one created by TASK1. TASK2 will create a new instance of the
expanded view. During init it will move the TaskView to the expanded
view it created. TASK2 schedules work on the main thread to update
bubble with the new expanded view it created.
Now TASK1 work, that it scheduled on the main thread, starts running. It
will see that the bubble is not inflated and proceeds to update the
bubble expanded view with the view it inflated. But this view no longer
has the TaskView since TASK2 removed it.
Work that TASK2 scheduled on main thread starts running now. Since
bubble views were set by TASK1, the views from TASK2 are discarded. This
also includes the TaskView that TASK2 added to the expanded view it
created as part of init.

The fix is to ensure that expanded views are only initialized on main
thread. Removing the chance for two background tasks updating the view
hierarchy independently. And also making sure that we only init only if
views are not set already.

Bug: 353894869
Test: run ShowMultipleBubblesAndSwitchTest 100 times with ABTD before
  and after applying changes
Flag: com.android.wm.shell.bubble_view_info_executors

Change-Id: Iccf1fb3700af87393ec22b8416a1df5c431d6a2b
parent 64dc0466
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment