Closed Bug 1340301 Opened 6 years ago Closed 1 year ago

APZInputBridgeChild for Android GPU process needs to be callable from UI thread.


(GeckoView :: Sandboxing, defect, P5)



(firefox54 wontfix, firefox96 fixed)

96 Branch
Tracking Status
firefox54 --- wontfix
firefox96 --- fixed


(Reporter: rbarker, Assigned: jnicol)




(1 file)

Currently, the APZCTreeManagerChild is created and invoked on the main thread. This works for non-android platforms because the controller thread and the main thread are the same. However, on android, the controller thread is the UI thread. Invoking the APZCTreeManagerChild from the UI thread on android will cause our IPC stack to assert. Rather than using the built in IPDL constructors, the creation of APZCTreeManager[Child|Parent] will need to use Endpoints so that the APZCTreeManagerChild may be initialized on the UI thread on Android.
Assignee: nobody → rbarker
Blocks: 1331109
With the changes in bug 1441324 APZCTreeManager can be left as-is. Instead you'll want to move the PAPZInputBridge to be created as a new top-level protocol (rather than being a subprotocol of PGPU) with the child side on the Java UI thread in the UI process, and the parent side on the main thread in the GPU process.
Summary: APZCTreeManagerChild for Android GPU process needs to be callable from UI thread. → APZInputBridgeChild for Android GPU process needs to be callable from UI thread.
Product: Firefox for Android → GeckoView
Assignee: rbarker → nobody
Assignee: nobody → jnicol

On Android the APZ controller thread is the android UI thread, rather
than the Gecko main thread as on other platforms. There some places
where the main thread requires to call IAPZCTreeManager functions that
must run on the controller thread. Currently we use the function
DispatchToControllerThread() prior to calling various IAPZCTreeManager
APIs to achieve this.

This works just fine for now, as there is no GPU process on
Android. However, once we do add a GPU process we will encounter

Firstly, there will now be a cross-process APZInputBridge rather than
using an in-process APZCTreeManager. The PAPZInputBridge protocol is
managed by PGPU, and therefore must run on the main thread in the
parent process. The input we require to send over the bridge, however,
originates from the UI thread.

To solve this we can convert PAPZInputBridge to a top-level protocol,
and bind it to the UI thread on Android. We can then send input
directly from the UI thread without issues.

Secondly, the PAPZCTreeManager protocol must also run from the main
thread in the parent process, as it is managed by
PCompositorBridge. Unlike PAPZInputBridge we cannot convert
PAPZCTreeManager in to a top level protocol, as it relies on the
ordering guarantees with PCompositorBridge.

We must therefore ensure that we only dispatch IAPZCTreeManager calls
to the controller thread when using an in-process
APZCTreeManager. Out-of-process calls, on the other hand, must be
dispatched to the main thread where we can send IPDL commands from. To
do this, we move the dispatch logic away from the callsites of
IAPZCTreeManager APIs, and in to the APZCTreeManager and
APZCTreeManagerChild implementations themselves.

Pushed by
Ensure APZ functions are called from correct threads on Android with GPU process. r=botond
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch

Moving GPU process bugs to the new GeckoView::Sandboxing component.

Component: General → Sandboxing
You need to log in before you can comment on or make changes to this bug.