Correct use of mojo::IsolatedConnection?

17 views
Skip to first unread message

Yuwei Huang

unread,
Oct 20, 2021, 2:49:27 PM10/20/21
to Daniel Cheng, Ken Rockot, chromi...@chromium.org, Joe Downing
Hi Mojo engineers,

I'm working on a program (a native messaging host) that forwards WebAuthn commands to the Chrome Remote Desktop host/daemon process. My current attempt opens two IsolatedConnections to the same host process (for different mojo interfaces) on different NamedPlatformChannels. We are using IsolatedConnections and NamedPlatformChannels since the host process and the WebAuthn NMH aren't in the same process launching graph. The second connection in the WebAuthn NMH will either get connection refused, or the mojo remote will get closed immediately after it's open. Here is a CL with a minimal reproducing executable: crrev.com/c/3234660. You just need to run it once without any flags then run it again with "--client".

It looks like the only other place that uses IsolatedConnection is chrome/service/service_process.cc, and it's using a single IsolatedConnection with an InterfaceProvider for passing handles around. I think this should also fix our problem, but I'd like to make sure we that don't have other API misuse, and understand why multiple IsolatedConnections wouldn't work.

Thanks!
Yuwei

Yuwei Huang

unread,
Oct 22, 2021, 2:14:10 AM10/22/21
to Daniel Cheng, Ken Rockot, chromi...@chromium.org, Joe Downing
Sorry that I had a bug in my repro CL. So the behavior after the bug is fixed is that the first isolated connection is closed after the second isolated connection is made. Another interesting finding is that it appears you can only have one isolated connection for each host-client pair, but you can make as many connections as you want as long as either the host process or the client process is different.

Daniel Cheng

unread,
Oct 27, 2021, 12:16:59 AM10/27/21
to Yuwei Huang, Ken Rockot, chromi...@chromium.org, Joe Downing
Sorry for the belated reply here.

I'm not very familiar with IsolatedConnection, so rockot@ might be able to comment more. If you want to investigate more yourself, I would add a disconnect handler and start tracing backwards to see where the disconnection is coming from.

If you want to have multiple message pipes going over this IsolatedConnection, bootstrapping it with some broker interface that vends other interfaces (e.g. like the InterfaceProvider solution linked above) sounds right to me.

Daniel

Ken Rockot

unread,
Oct 27, 2021, 11:26:51 AM10/27/21
to Daniel Cheng, Yuwei Huang, chromi...@chromium.org, Joe Downing
On Tue, Oct 26, 2021 at 9:16 PM Daniel Cheng <dch...@google.com> wrote:
Sorry for the belated reply here. 

I'm not very familiar with IsolatedConnection, so rockot@ might be able to comment more. If you want to investigate more yourself, I would add a disconnect handler and start tracing backwards to see where the disconnection is coming from.

It's true, only one isolated connection is supported per process pair. Establishing a second will break the first. But you shouldn't ever really need more than one.


If you want to have multiple message pipes going over this IsolatedConnection, bootstrapping it with some broker interface that vends other interfaces (e.g. like the InterfaceProvider solution linked above) sounds right to me.

That seems like the right thing to do if you want multiple interfaces. Use the isolated connection to bootstrap one pipe, use that pipe to connect other pipes. This is in line with how invitations (isolated or otherwise) are intended to be used.

Yuwei Huang

unread,
Oct 27, 2021, 2:47:58 PM10/27/21
to Ken Rockot, Daniel Cheng, chromi...@chromium.org, Joe Downing
Thank you Daniel and Ken for the information!

We are thinking if we should implement a generic interface to pass raw message pipes around like the InterfaceProvider, or if we should just implement a facade interface that passes pending_remotes/pending_receivers around like Crosapi. Passing raw message pipes seems more flexible, but we will lose strong typing when we bind remotes or receivers.

Looks like we are now more inclined to do it in the Crosapi stype, but I'd like to get some inputs from mojo experts.

Thanks!
Yuwei
Reply all
Reply to author
Forward
0 new messages