Stopping components using fuchsia.component.Realm

8 views
Skip to first unread message

Xyan Bhatnagar

unread,
Mar 14, 2022, 2:38:50 PM3/14/22
to component-framework-dev
Hey folks,

Is it reasonable for a parent component to use the fuchsia.component.Realm protocol to stop a child component instance?

I'm imagining this as a new method `StopChild` which accepts a ChildRef and blocks until the child component has stopped. It can even return the exit code it got from the program.

Thoughts?

- Xyan

Justin Mattson

unread,
Mar 14, 2022, 2:47:18 PM3/14/22
to Xyan Bhatnagar, component-framework-dev
This seems like it would make an interesting shift in our stance of "everything runs for a reason". This statement is specific, but more generally I think we have a stance of "everything is in a given state for a reason". The "reason" we've been trying to avoid is "because another component said so".

So far we've had ways to start a child directly, but I am secretly (oops, no longer a secret) hopeful we could find a way to deprecate these. For example, if we had the necessary APIs to define a dynamic child and its routing to the framework then maybe it would be unnecessary to start the component directly.

Maybe we can't pull this off or maybe we can't pull it off now, but if we add a StopChild API we should try to understand whether this is tech debt.

Cheers,
Justin

--
All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
---
You received this message because you are subscribed to the Google Groups "component-framework-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to component-framewo...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/component-framework-dev/CAHacFysUC__5He42xV5SubxSsUxBSSOCwT0CA%2Bk84%3DmniAZhDA%40mail.gmail.com.

Suraj Malhotra

unread,
Mar 14, 2022, 3:07:43 PM3/14/22
to Justin Mattson, Xyan Bhatnagar, component-framework-dev
Starting a child via dependencies is a non-starter for drivers. Until enumeration has occurred, you don't really understand what components you need to instantiate to make those services available. It needs to be done eagerly. The best you could do is defer device enumeration until someone tries using devfs or services exported by the driver collection. We've talked through this a few times in the DF/CF sync in the past.

As far as needing the ability to control a child component from a parent, we will always need the ability to stop a component due to an event like the usb device being unplugged. I think we manage with the existing API just fine (closing the ComponentController channel seems to work as we don't need to know when it's completed), but removing our ability to do this would be problematic.

Gabe Schine

unread,
Mar 14, 2022, 3:42:28 PM3/14/22
to Suraj Malhotra, Justin Mattson, Xyan Bhatnagar, component-framework-dev
Xyan, are you asking specifically about a StopChild() for statically defined children?

We will not remove the ability for a parent to effectively controls a child's lifecycle if it opts to do so.



--
Gabe Schine
Software Engineer / Manager

Xyan Bhatnagar

unread,
Mar 14, 2022, 5:32:41 PM3/14/22
to Gabe Schine, Suraj Malhotra, Justin Mattson, component-framework-dev
On Mon, Mar 14, 2022 at 3:42 PM Gabe Schine <tha...@google.com> wrote:
Xyan, are you asking specifically about a StopChild() for statically defined children?

For static and dynamic children. The ability for a parent to stop a child using a public API came up recently and it seems like a reasonable request. Parents already have a good amount of control over their children via the Realm protocol.

Gabe Schine

unread,
Mar 14, 2022, 5:34:07 PM3/14/22
to Xyan Bhatnagar, Suraj Malhotra, Justin Mattson, component-framework-dev
Ack.

Maybe we can move this discussion to a feature request bug?

Dave Smith

unread,
Mar 14, 2022, 5:58:09 PM3/14/22
to Gabe Schine, Xyan Bhatnagar, Suraj Malhotra, Justin Mattson, component-framework-dev
Admittedly, the request came from me so I just filed fxbug.dev/95569

Dave Smith | Developer Relations | smit...@google.com | @devunwired


Yegor Pomortsev

unread,
Mar 14, 2022, 6:11:46 PM3/14/22
to Dave Smith, Gabe Schine, Xyan Bhatnagar, Suraj Malhotra, Justin Mattson, component-framework-dev
Please also see fxbug.dev/94153 [Component Feedback]: Improve consistency of lifecycle operations on child components

Dave Smith

unread,
Mar 14, 2022, 6:14:13 PM3/14/22
to Yegor Pomortsev, Gabe Schine, Xyan Bhatnagar, Suraj Malhotra, Justin Mattson, component-framework-dev
I like yours better, duped :)


Dave Smith | Developer Relations | smit...@google.com | @devunwired

Justin Mattson

unread,
Mar 15, 2022, 12:40:49 PM3/15/22
to Dave Smith, Yegor Pomortsev, Gabe Schine, Xyan Bhatnagar, Suraj Malhotra, component-framework-dev
To be clear my secret hope is that we can find a model that serves all clients well and avoids explicit lifecycle control of children. It is not my secret hope to foist this model on component authors by force.

I think we manage with the existing API just fine (closing the ComponentController channel seems to work as we don't need to know when it's completed), but removing our ability to do this would be problematic.

Being in control of the runner here affords DF some control that many authors don't have since that channel is part of the contract between Runners and the component manager. 

Gary Bressler

unread,
Mar 15, 2022, 4:26:36 PM3/15/22
to Justin Mattson, Dave Smith, Yegor Pomortsev, Gabe Schine, Xyan Bhatnagar, Suraj Malhotra, component-framework-dev
Were there concrete use case(s) motivating the request for StopChild? If so, could you mention them on the bug?

With more context, it'll be easier to evaluate what kind of API is needed to solve the requirements. If the client wants guarantees that the entire sub-realm will be stopped, the existing Stop API from LifecycleController might not be sufficient. Even if the stop is recursive, one of the components in the realm could reanimate if something binds to it. 

Reply all
Reply to author
Forward
0 new messages