New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 810084 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner: ----
Closed: Today
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Expose a Java-equivalent of ThreadSafeInterfacePtr

Project Member Reported by lhchavez@chromium.org, Feb 7 2018

Issue description

In the Android side of ARC, the threading story is much more complicated than the one in Chrome. Requests typically come into a pool of Binder threads, and these do not have a Chrome message loop attached to them, so it's difficult to have an ergonomic way of making Mojo calls.

The current workaround we have is wrapping all the accesses to Mojo objects with a synchronized block, which effectively serializes them all and that gets rid of the vast majority of the problems, but there are still a few places where this technique is not enough. Namely, if there is a disconnect event, that can be dispatched from the main thread and modify internal state in a way the synchronized blocks cannot protect.

So, it'd be a good idea to solve this problem the right way and instead of us wrapping stuff, the bindings would allow us to expose a thread-safe object that can be called from any thread without any worries. Having an automatic proxy like ThreadSafeInterfacePtr in Java would completely solve the issue, but due to the lack of template metaprogramming, this _might_ need to come from the bindings, probably under a flag.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jul 24

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/18214c8d52183ae1b0fee5db0e2fabcc3494f824

commit 18214c8d52183ae1b0fee5db0e2fabcc3494f824
Author: Luis Hector Chavez <lhchavez@google.com>
Date: Tue Jul 24 04:52:32 2018

Mojo: Add a way to create thread-safe interfaces in Java

This change adds Interface.Manager.buildThreadSafeProxy(), which is
roughly analogous to mojo::ThreadSafeInterfacePtr<T>. Given that Java
does not have move-only semantics, the Proxy object that is passed is
unbound and a new object is returned.

Bug:  810084 
Test: cheets_ContainerSmokeTest in Chrome OS
Change-Id: I6565f9e526e3fa8f8cb222cb8cd11e95bb57f7d3
Reviewed-on: https://chromium-review.googlesource.com/1147320
Reviewed-by: Ken Rockot <rockot@chromium.org>
Commit-Queue: Luis Hector Chavez <lhchavez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577429}
[modify] https://crrev.com/18214c8d52183ae1b0fee5db0e2fabcc3494f824/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java

Cc: -roc...@chromium.org rockot@google.com

Comment 3 by oksamyt@chromium.org, Today (16 hours ago)

Status: Fixed (was: Untriaged)

Sign in to add a comment