Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
flutter_runner::Runner Class Referencefinal

#include <runner.h>

Inheritance diagram for flutter_runner::Runner:

Public Member Functions

 Runner (fml::RefPtr< fml::TaskRunner > task_runner, sys::ComponentContext *context)
 
 ~Runner ()
 

Private Member Functions

void Start (fuchsia::component::runner::ComponentStartInfo start_info, fidl::InterfaceRequest< fuchsia::component::runner::ComponentController > controller) override
 

Detailed Description

Publishes the CF v2 runner service.

Each component will be run on a separate thread dedicated to that component.

TODO(fxb/50694): Add unit tests for CF v2.

Definition at line 31 of file runner.h.

Constructor & Destructor Documentation

◆ Runner()

Runner::Runner ( fml::RefPtr< fml::TaskRunner task_runner,
sys::ComponentContext *  context 
)

Definition at line 153 of file runner.cc.

155 : task_runner_(task_runner), context_(context) {
156#if !defined(DART_PRODUCT)
157 // The VM service isolate uses the process-wide namespace. It writes the
158 // vm service protocol port under /tmp. The VMServiceObject exposes that
159 // port number to The Hub.
160 context_->outgoing()->debug_dir()->AddEntry(
162 std::make_unique<dart_utils::VMServiceObject>());
163
164 inspect::Inspector* inspector = dart_utils::RootInspectNode::GetInspector();
165 inspector->GetRoot().CreateLazyValues(
166 "vmservice_port",
167 [&]() {
168 inspect::Inspector inspector;
169 dart_utils::VMServiceObject::LazyEntryVector out;
171 std::string name = "";
172 if (!out.empty()) {
173 name = out[0].name;
174 }
175 inspector.GetRoot().CreateString("vm_service_port", name, &inspector);
176 return fpromise::make_ok_promise(inspector);
177 },
178 inspector);
179
180 SetupTraceObserver();
181#endif // !defined(DART_PRODUCT)
182
184
185 SetupICU();
186
188
189 SetThreadName("io.flutter.runner.main");
190
191 context_->outgoing()
192 ->AddPublicService<fuchsia::component::runner::ComponentRunner>(
193 std::bind(&Runner::RegisterComponentV2, this, std::placeholders::_1));
194
195#if !defined(DART_PRODUCT)
197 RegisterProfilerSymbols("pkg/data/flutter_aot_runner.dartprofilersymbols",
198 "");
199 } else {
200 RegisterProfilerSymbols("pkg/data/flutter_jit_runner.dartprofilersymbols",
201 "");
202 }
203#endif // !defined(DART_PRODUCT)
204}
static void Init()
static inspect::Inspector * GetInspector()
void GetContents(LazyEntryVector *out_vector) const override
static constexpr const char * kPortDirName
DART_EXPORT bool Dart_IsPrecompiledRuntime(void)
const char * name
Definition fuchsia.cc:50
static void SetThreadName(const std::string &thread_name)
Definition runner.cc:135
static void RegisterProfilerSymbols(const char *symbols_path, const char *dso_name)
Definition runner.cc:142
static void SetProcessName()
Definition runner.cc:119

◆ ~Runner()

Runner::~Runner ( )

Definition at line 206 of file runner.cc.

206 {
207 context_->outgoing()
208 ->RemovePublicService<fuchsia::component::runner::ComponentRunner>();
209
210#if !defined(DART_PRODUCT)
211 trace_observer_->Stop();
212#endif // !defined(DART_PRODUCT)
213}

Member Function Documentation

◆ Start()

void Runner::Start ( fuchsia::component::runner::ComponentStartInfo  start_info,
fidl::InterfaceRequest< fuchsia::component::runner::ComponentController >  controller 
)
overrideprivate

Definition at line 223 of file runner.cc.

226 {
227 // TRACE_DURATION currently requires that the string data does not change
228 // in the traced scope. Since |package| gets moved in the ComponentV2::Create
229 // call below, we cannot ensure that |package.resolved_url| does not move or
230 // change, so we make a copy to pass to TRACE_DURATION.
231 // TODO(PT-169): Remove this copy when TRACE_DURATION reads string arguments
232 // eagerly.
233 const std::string url_copy = start_info.resolved_url();
234 TRACE_EVENT1("flutter", "Start", "url", url_copy.c_str());
235
236 // Notes on component termination: Components typically terminate on the
237 // thread on which they were created. This usually means the thread was
238 // specifically created to host the component. But we want to ensure that
239 // access to the active components collection is made on the same thread. So
240 // we capture the runner in the termination callback. There is no risk of
241 // there being multiple component runner instances in the process at the same
242 // time. So it is safe to use the raw pointer.
243 ComponentV2::TerminationCallback termination_callback =
244 [component_runner = this](const ComponentV2* component) {
245 component_runner->task_runner_->PostTask(
246 [component_runner, component]() {
247 component_runner->OnComponentV2Terminate(component);
248 });
249 };
250
251 ActiveComponentV2 active_component = ComponentV2::Create(
252 std::move(termination_callback), std::move(start_info),
253 context_->svc() /* runner_incoming_services */, std::move(controller));
254
255 auto key = active_component.component.get();
256 active_components_v2_[key] = std::move(active_component);
257}
static ActiveComponentV2 Create(TerminationCallback termination_callback, fuchsia::component::runner::ComponentStartInfo start_info, std::shared_ptr< sys::ServiceDirectory > runner_incoming_services, fidl::InterfaceRequest< fuchsia::component::runner::ComponentController > controller)
fit::function< void(const ComponentV2 *)> TerminationCallback
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)

The documentation for this class was generated from the following files: