Flutter Engine
engine.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "engine.h"
6 
7 #include <lib/async/cpp/task.h>
8 #include <zircon/status.h>
9 
10 #include "../runtime/dart/utils/files.h"
11 #include "flow/embedded_views.h"
12 #include "flutter/common/task_runners.h"
13 #include "flutter/fml/make_copyable.h"
14 #include "flutter/fml/synchronization/waitable_event.h"
15 #include "flutter/fml/task_runner.h"
16 #include "flutter/runtime/dart_vm_lifecycle.h"
17 #include "flutter/shell/common/rasterizer.h"
18 #include "flutter/shell/common/run_configuration.h"
19 #include "third_party/skia/include/ports/SkFontMgr_fuchsia.h"
20 
23 #include "fuchsia_intl.h"
24 #include "platform_view.h"
25 #include "surface.h"
26 #include "task_runner_adapter.h"
27 #include "thread.h"
28 
29 #if defined(LEGACY_FUCHSIA_EMBEDDER)
30 #include "compositor_context.h" // nogncheck
31 #endif
32 
33 namespace flutter_runner {
34 namespace {
35 
36 void UpdateNativeThreadLabelNames(const std::string& label,
37  const flutter::TaskRunners& runners) {
38  auto set_thread_name = [](fml::RefPtr<fml::TaskRunner> runner,
39  std::string prefix, std::string suffix) {
40  if (!runner) {
41  return;
42  }
43  fml::TaskRunner::RunNowOrPostTask(runner, [name = prefix + suffix]() {
44  zx::thread::self()->set_property(ZX_PROP_NAME, name.c_str(), name.size());
45  });
46  };
47  set_thread_name(runners.GetPlatformTaskRunner(), label, ".platform");
48  set_thread_name(runners.GetUITaskRunner(), label, ".ui");
49  set_thread_name(runners.GetRasterTaskRunner(), label, ".raster");
50  set_thread_name(runners.GetIOTaskRunner(), label, ".io");
51 }
52 
53 fml::RefPtr<flutter::PlatformMessage> MakeLocalizationPlatformMessage(
54  const fuchsia::intl::Profile& intl_profile) {
55  return fml::MakeRefCounted<flutter::PlatformMessage>(
56  "flutter/localization", MakeLocalizationPlatformMessageData(intl_profile),
57  nullptr);
58 }
59 
60 } // namespace
61 
63  std::string thread_label,
64  std::shared_ptr<sys::ServiceDirectory> svc,
65  std::shared_ptr<sys::ServiceDirectory> runner_services,
66  flutter::Settings settings,
68  fuchsia::ui::views::ViewToken view_token,
69  scenic::ViewRefPair view_ref_pair,
70  UniqueFDIONS fdio_ns,
71  fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
72  FlutterRunnerProductConfiguration product_config)
73  : delegate_(delegate),
74  thread_label_(std::move(thread_label)),
75 #if defined(LEGACY_FUCHSIA_EMBEDDER)
76  use_legacy_renderer_(product_config.use_legacy_renderer()),
77 #endif
78  weak_factory_(this) {
79  if (zx::event::create(0, &vsync_event_) != ZX_OK) {
80  FML_DLOG(ERROR) << "Could not create the vsync event.";
81  return;
82  }
83 
84  // Get the task runners from the managed threads. The current thread will be
85  // used as the "platform" thread.
86  const flutter::TaskRunners task_runners(
87  thread_label_, // Dart thread labels
88  CreateFMLTaskRunner(async_get_default_dispatcher()), // platform
89  CreateFMLTaskRunner(threads_[0].dispatcher()), // raster
90  CreateFMLTaskRunner(threads_[1].dispatcher()), // ui
91  CreateFMLTaskRunner(threads_[2].dispatcher()) // io
92  );
93  UpdateNativeThreadLabelNames(thread_label_, task_runners);
94 
95  // Connect to Scenic.
96  auto scenic = svc->Connect<fuchsia::ui::scenic::Scenic>();
97  fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session;
98  fidl::InterfaceHandle<fuchsia::ui::scenic::SessionListener> session_listener;
99  auto session_listener_request = session_listener.NewRequest();
100  fidl::InterfaceHandle<fuchsia::ui::views::Focuser> focuser;
101  scenic->CreateSession2(session.NewRequest(), session_listener.Bind(),
102  focuser.NewRequest());
103 
104  // Make clones of the `ViewRef` before sending it down to Scenic.
105  fuchsia::ui::views::ViewRef platform_view_ref, isolate_view_ref;
106  view_ref_pair.view_ref.Clone(&platform_view_ref);
107  view_ref_pair.view_ref.Clone(&isolate_view_ref);
108 
109  // Session is terminated on the raster thread, but we must terminate ourselves
110  // on the platform thread.
111  //
112  // This handles the fidl error callback when the Session connection is
113  // broken. The SessionListener interface also has an OnError method, which is
114  // invoked on the platform thread (in PlatformView).
115  fml::closure session_error_callback = [dispatcher =
116  async_get_default_dispatcher(),
117  weak = weak_factory_.GetWeakPtr()]() {
118  async::PostTask(dispatcher, [weak]() {
119  if (weak) {
120  weak->Terminate();
121  }
122  });
123  };
124 
125  // Set up the session connection and other Scenic helpers on the raster
126  // thread. We also need to wait for the external view embedder to be setup
127  // before creating the shell.
128  fml::AutoResetWaitableEvent view_embedder_latch;
130  [this, session = std::move(session),
131  session_error_callback = std::move(session_error_callback),
132  view_token = std::move(view_token),
133  view_ref_pair = std::move(view_ref_pair),
134  max_frames_in_flight = product_config.get_max_frames_in_flight(),
135  vsync_handle = vsync_event_.get(), &view_embedder_latch]() mutable {
136  session_connection_.emplace(
137  thread_label_, std::move(session),
138  std::move(session_error_callback), [](auto) {}, vsync_handle,
139  max_frames_in_flight);
140  surface_producer_.emplace(session_connection_->get());
141 #if defined(LEGACY_FUCHSIA_EMBEDDER)
142  if (use_legacy_renderer_) {
143  legacy_external_view_embedder_ =
144  std::make_shared<flutter::SceneUpdateContext>(
145  thread_label_, std::move(view_token),
146  std::move(view_ref_pair), session_connection_.value());
147  } else
148 #endif
149  {
150  external_view_embedder_ =
151  std::make_shared<FuchsiaExternalViewEmbedder>(
152  thread_label_, std::move(view_token),
153  std::move(view_ref_pair), session_connection_.value(),
154  surface_producer_.value());
155  }
156  view_embedder_latch.Signal();
157  }));
158  view_embedder_latch.Wait();
159 
160  // Grab the parent environment services. The platform view may want to
161  // access some of these services.
162  fuchsia::sys::EnvironmentPtr environment;
163  svc->Connect(environment.NewRequest());
164  fidl::InterfaceHandle<fuchsia::sys::ServiceProvider>
165  parent_environment_service_provider;
166  environment->GetServices(parent_environment_service_provider.NewRequest());
167  environment.Unbind();
168 
169  OnEnableWireframe on_enable_wireframe_callback = std::bind(
170  &Engine::DebugWireframeSettingsChanged, this, std::placeholders::_1);
171 
172  OnCreateView on_create_view_callback =
173  std::bind(&Engine::CreateView, this, std::placeholders::_1,
174  std::placeholders::_2, std::placeholders::_3);
175 
176  OnUpdateView on_update_view_callback =
177  std::bind(&Engine::UpdateView, this, std::placeholders::_1,
178  std::placeholders::_2, std::placeholders::_3);
179 
180  OnDestroyView on_destroy_view_callback =
181  std::bind(&Engine::DestroyView, this, std::placeholders::_1);
182 
183  OnCreateSurface on_create_surface_callback =
184  std::bind(&Engine::CreateSurface, this);
185 
186  // SessionListener has a OnScenicError method; invoke this callback on the
187  // platform thread when that happens. The Session itself should also be
188  // disconnected when this happens, and it will also attempt to terminate.
189  fit::closure on_session_listener_error_callback =
190  [dispatcher = async_get_default_dispatcher(),
191  weak = weak_factory_.GetWeakPtr()]() {
192  async::PostTask(dispatcher, [weak]() {
193  if (weak) {
194  weak->Terminate();
195  }
196  });
197  };
198 
199  // Setup the callback that will instantiate the platform view.
201  on_create_platform_view = fml::MakeCopyable(
202  [debug_label = thread_label_, view_ref = std::move(platform_view_ref),
203  runner_services,
204  parent_environment_service_provider =
205  std::move(parent_environment_service_provider),
206  session_listener_request = std::move(session_listener_request),
207  focuser = std::move(focuser),
208  on_session_listener_error_callback =
209  std::move(on_session_listener_error_callback),
210  on_enable_wireframe_callback =
211  std::move(on_enable_wireframe_callback),
212  on_create_view_callback = std::move(on_create_view_callback),
213  on_update_view_callback = std::move(on_update_view_callback),
214  on_destroy_view_callback = std::move(on_destroy_view_callback),
215  on_create_surface_callback = std::move(on_create_surface_callback),
216  external_view_embedder = GetExternalViewEmbedder(),
217  vsync_offset = product_config.get_vsync_offset(),
218  vsync_handle = vsync_event_.get()](flutter::Shell& shell) mutable {
219  return std::make_unique<flutter_runner::PlatformView>(
220  shell, // delegate
221  debug_label, // debug label
222  std::move(view_ref), // view ref
223  shell.GetTaskRunners(), // task runners
224  std::move(runner_services),
225  std::move(parent_environment_service_provider), // services
226  std::move(session_listener_request), // session listener
227  std::move(focuser),
228  std::move(on_session_listener_error_callback),
229  std::move(on_enable_wireframe_callback),
230  std::move(on_create_view_callback),
231  std::move(on_update_view_callback),
232  std::move(on_destroy_view_callback),
233  std::move(on_create_surface_callback),
234  external_view_embedder, // external view embedder
235  std::move(vsync_offset), // vsync offset
236  vsync_handle);
237  });
238 
239  // Setup the callback that will instantiate the rasterizer.
241 #if defined(LEGACY_FUCHSIA_EMBEDDER)
242  on_create_rasterizer = [this](flutter::Shell& shell) {
243  if (use_legacy_renderer_) {
244  FML_DCHECK(session_connection_);
245  FML_DCHECK(surface_producer_);
246  FML_DCHECK(legacy_external_view_embedder_);
247 
248  auto compositor_context =
249  std::make_unique<flutter_runner::CompositorContext>(
250  session_connection_.value(), surface_producer_.value(),
251  legacy_external_view_embedder_);
252  return std::make_unique<flutter::Rasterizer>(
253  shell, std::move(compositor_context));
254  } else {
255  return std::make_unique<flutter::Rasterizer>(shell);
256  }
257  };
258 #else
259  on_create_rasterizer = [](flutter::Shell& shell) {
260  return std::make_unique<flutter::Rasterizer>(shell);
261  };
262 #endif
263 
265  std::bind(&Engine::OnMainIsolateStart, this);
267  std::bind([weak = weak_factory_.GetWeakPtr(),
268  runner = task_runners.GetPlatformTaskRunner()]() {
269  runner->PostTask([weak = std::move(weak)] {
270  if (weak) {
271  weak->OnMainIsolateShutdown();
272  }
273  });
274  });
275 
276  auto vm = flutter::DartVMRef::Create(settings);
277 
278  if (!isolate_snapshot) {
279  isolate_snapshot = vm->GetVMData()->GetIsolateSnapshot();
280  }
281 
282  {
283  TRACE_EVENT0("flutter", "CreateShell");
284  shell_ = flutter::Shell::Create(
285  std::move(task_runners), // host task runners
286  flutter::PlatformData(), // default window data
287  std::move(settings), // shell launch settings
288  std::move(isolate_snapshot), // isolate snapshot
289  std::move(on_create_platform_view), // platform view create callback
290  std::move(on_create_rasterizer), // rasterizer create callback
291  std::move(vm) // vm reference
292  );
293  }
294 
295  if (!shell_) {
296  FML_LOG(ERROR) << "Could not launch the shell.";
297  return;
298  }
299 
300  // Shell has been created. Before we run the engine, setup the isolate
301  // configurator.
302  {
303  fuchsia::sys::EnvironmentPtr environment;
304  svc->Connect(environment.NewRequest());
305 
306  isolate_configurator_ = std::make_unique<IsolateConfigurator>(
307  std::move(fdio_ns), //
308  std::move(environment), //
309  directory_request.TakeChannel(), //
310  std::move(isolate_view_ref.reference) //
311  );
312  }
313 
314  // This platform does not get a separate surface platform view creation
315  // notification. Fire one eagerly.
316  shell_->GetPlatformView()->NotifyCreated();
317 
318  // Connect to the intl property provider. If the connection fails, the
319  // initialization of the engine will simply proceed, printing a warning
320  // message. The engine will be fully functional, except that the user's
321  // locale preferences would not be communicated to flutter engine.
322  {
323  intl_property_provider_.set_error_handler([](zx_status_t status) {
324  FML_LOG(WARNING) << "Failed to connect to "
325  << fuchsia::intl::PropertyProvider::Name_ << ": "
326  << zx_status_get_string(status)
327  << " This is not a fatal error, but the user locale "
328  << " preferences will not be forwarded to flutter apps";
329  });
330 
331  // Note that we're using the runner's services, not the component's.
332  // Flutter locales should be updated regardless of whether the component has
333  // direct access to the fuchsia.intl.PropertyProvider service.
334  ZX_ASSERT(runner_services->Connect(intl_property_provider_.NewRequest()) ==
335  ZX_OK);
336 
337  auto get_profile_callback = [flutter_runner_engine =
338  weak_factory_.GetWeakPtr()](
339  const fuchsia::intl::Profile& profile) {
340  if (!flutter_runner_engine) {
341  return;
342  }
343  if (!profile.has_locales()) {
344  FML_LOG(WARNING) << "Got intl Profile without locales";
345  }
346  auto message = MakeLocalizationPlatformMessage(profile);
347  FML_VLOG(-1) << "Sending LocalizationPlatformMessage";
348  flutter_runner_engine->shell_->GetPlatformView()->DispatchPlatformMessage(
349  message);
350  };
351 
352  FML_VLOG(-1) << "Requesting intl Profile";
353 
354  // Make the initial request
355  intl_property_provider_->GetProfile(get_profile_callback);
356 
357  // And register for changes
358  intl_property_provider_.events().OnChange = [this, runner_services,
359  get_profile_callback]() {
360  FML_VLOG(-1) << fuchsia::intl::PropertyProvider::Name_ << ": OnChange";
361  runner_services->Connect(intl_property_provider_.NewRequest());
362  intl_property_provider_->GetProfile(get_profile_callback);
363  };
364  }
365 
366  // Launch the engine in the appropriate configuration.
367  auto run_configuration = flutter::RunConfiguration::InferFromSettings(
368  shell_->GetSettings(), shell_->GetTaskRunners().GetIOTaskRunner());
369 
370  auto on_run_failure = [weak = weak_factory_.GetWeakPtr()]() {
371  // The engine could have been killed by the caller right after the
372  // constructor was called but before it could run on the UI thread.
373  if (weak) {
374  weak->Terminate();
375  }
376  };
377 
378  // Connect to the system font provider.
379  fuchsia::fonts::ProviderSyncPtr sync_font_provider;
380  svc->Connect(sync_font_provider.NewRequest());
381 
382  shell_->GetTaskRunners().GetUITaskRunner()->PostTask(
383  fml::MakeCopyable([engine = shell_->GetEngine(), //
384  run_configuration = std::move(run_configuration), //
385  sync_font_provider = std::move(sync_font_provider), //
386  on_run_failure //
387  ]() mutable {
388  if (!engine) {
389  return;
390  }
391 
392  // Set default font manager.
393  engine->GetFontCollection().GetFontCollection()->SetDefaultFontManager(
394  SkFontMgr_New_Fuchsia(std::move(sync_font_provider)));
395 
396  if (engine->Run(std::move(run_configuration)) ==
398  on_run_failure();
399  }
400  }));
401 }
402 
404  shell_.reset();
405  for (auto& thread : threads_) {
406  thread.Quit();
407  }
408  for (auto& thread : threads_) {
409  thread.Join();
410  }
411 }
412 
413 std::optional<uint32_t> Engine::GetEngineReturnCode() const {
414  if (!shell_) {
415  return std::nullopt;
416  }
417  std::optional<uint32_t> code;
420  shell_->GetTaskRunners().GetUITaskRunner(),
421  [&latch, &code, engine = shell_->GetEngine()]() {
422  if (engine) {
423  code = engine->GetUIIsolateReturnCode();
424  }
425  latch.Signal();
426  });
427  latch.Wait();
428  return code;
429 }
430 
431 static void CreateCompilationTrace(Dart_Isolate isolate) {
432  Dart_EnterIsolate(isolate);
433 
434  {
435  Dart_EnterScope();
436  uint8_t* trace = nullptr;
437  intptr_t trace_length = 0;
438  Dart_Handle result = Dart_SaveCompilationTrace(&trace, &trace_length);
439  tonic::LogIfError(result);
440 
441  for (intptr_t start = 0; start < trace_length;) {
442  intptr_t end = start;
443  while ((end < trace_length) && trace[end] != '\n')
444  end++;
445 
446  std::string line(reinterpret_cast<char*>(&trace[start]), end - start);
447  FML_LOG(INFO) << "compilation-trace: " << line;
448 
449  start = end + 1;
450  }
451 
452  Dart_ExitScope();
453  }
454 
455  // Re-enter Dart scope to release the compilation trace's memory.
456 
457  {
458  Dart_EnterScope();
459  uint8_t* feedback = nullptr;
460  intptr_t feedback_length = 0;
461  Dart_Handle result = Dart_SaveTypeFeedback(&feedback, &feedback_length);
462  tonic::LogIfError(result);
463  const std::string kTypeFeedbackFile = "/data/dart_type_feedback.bin";
464  if (dart_utils::WriteFile(kTypeFeedbackFile,
465  reinterpret_cast<const char*>(feedback),
466  feedback_length)) {
467  FML_LOG(INFO) << "Dart type feedback written to " << kTypeFeedbackFile;
468  } else {
469  FML_LOG(ERROR) << "Could not write Dart type feedback to "
470  << kTypeFeedbackFile;
471  }
472  Dart_ExitScope();
473  }
474 
475  Dart_ExitIsolate();
476 }
477 
478 void Engine::OnMainIsolateStart() {
479  if (!isolate_configurator_ ||
480  !isolate_configurator_->ConfigureCurrentIsolate()) {
481  FML_LOG(ERROR) << "Could not configure some native embedder bindings for a "
482  "new root isolate.";
483  }
484  FML_DLOG(INFO) << "Main isolate for engine '" << thread_label_
485  << "' was started.";
486 
487  const intptr_t kCompilationTraceDelayInSeconds = 0;
488  if (kCompilationTraceDelayInSeconds != 0) {
489  Dart_Isolate isolate = Dart_CurrentIsolate();
490  FML_CHECK(isolate);
491  shell_->GetTaskRunners().GetUITaskRunner()->PostDelayedTask(
492  [engine = shell_->GetEngine(), isolate]() {
493  if (!engine) {
494  return;
495  }
496  CreateCompilationTrace(isolate);
497  },
498  fml::TimeDelta::FromSeconds(kCompilationTraceDelayInSeconds));
499  }
500 }
501 
502 void Engine::OnMainIsolateShutdown() {
503  FML_DLOG(INFO) << "Main isolate for engine '" << thread_label_
504  << "' shutting down.";
505  Terminate();
506 }
507 
508 void Engine::Terminate() {
509  delegate_.OnEngineTerminate(this);
510  // Warning. Do not do anything after this point as the delegate may have
511  // collected this object.
512 }
513 
514 void Engine::DebugWireframeSettingsChanged(bool enabled) {
515  FML_CHECK(shell_);
516 
517  shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask([this, enabled]() {
518 #if defined(LEGACY_FUCHSIA_EMBEDDER)
519  if (use_legacy_renderer_) {
520  FML_CHECK(legacy_external_view_embedder_);
521  legacy_external_view_embedder_->EnableWireframe(enabled);
522  } else
523 #endif
524  {
525  FML_CHECK(external_view_embedder_);
526  external_view_embedder_->EnableWireframe(enabled);
527  }
528  });
529 }
530 
531 void Engine::CreateView(int64_t view_id, bool hit_testable, bool focusable) {
532  FML_CHECK(shell_);
533 
534  shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask(
535  [this, view_id, hit_testable, focusable]() {
536 #if defined(LEGACY_FUCHSIA_EMBEDDER)
537  if (use_legacy_renderer_) {
538  FML_CHECK(legacy_external_view_embedder_);
539  legacy_external_view_embedder_->CreateView(view_id, hit_testable,
540  focusable);
541  } else
542 #endif
543  {
544  FML_CHECK(external_view_embedder_);
545  external_view_embedder_->CreateView(view_id);
546  external_view_embedder_->SetViewProperties(view_id, hit_testable,
547  focusable);
548  }
549  });
550 }
551 
552 void Engine::UpdateView(int64_t view_id, bool hit_testable, bool focusable) {
553  FML_CHECK(shell_);
554 
555  shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask(
556  [this, view_id, hit_testable, focusable]() {
557 #if defined(LEGACY_FUCHSIA_EMBEDDER)
558  if (use_legacy_renderer_) {
559  FML_CHECK(legacy_external_view_embedder_);
560  legacy_external_view_embedder_->UpdateView(view_id, hit_testable,
561  focusable);
562  } else
563 #endif
564  {
565  FML_CHECK(external_view_embedder_);
566  external_view_embedder_->SetViewProperties(view_id, hit_testable,
567  focusable);
568  }
569  });
570 }
571 
572 void Engine::DestroyView(int64_t view_id) {
573  FML_CHECK(shell_);
574 
575  shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask([this, view_id]() {
576 #if defined(LEGACY_FUCHSIA_EMBEDDER)
577  if (use_legacy_renderer_) {
578  FML_CHECK(legacy_external_view_embedder_);
579  legacy_external_view_embedder_->DestroyView(view_id);
580  } else
581 #endif
582  {
583  FML_CHECK(external_view_embedder_);
584  external_view_embedder_->DestroyView(view_id);
585  }
586  });
587 }
588 
589 std::unique_ptr<flutter::Surface> Engine::CreateSurface() {
590  return std::make_unique<Surface>(thread_label_, GetExternalViewEmbedder(),
591  surface_producer_->gr_context());
592 }
593 
594 std::shared_ptr<flutter::ExternalViewEmbedder>
595 Engine::GetExternalViewEmbedder() {
596  std::shared_ptr<flutter::ExternalViewEmbedder> external_view_embedder =
597  nullptr;
598 
599 #if defined(LEGACY_FUCHSIA_EMBEDDER)
600  if (use_legacy_renderer_) {
601  FML_CHECK(legacy_external_view_embedder_);
602  external_view_embedder = legacy_external_view_embedder_;
603  } else
604 #endif
605  {
606  FML_CHECK(external_view_embedder_);
607  external_view_embedder = external_view_embedder_;
608  }
609  FML_CHECK(external_view_embedder);
610 
611  return external_view_embedder;
612 }
613 
614 #if !defined(DART_PRODUCT)
616  Dart_Port main_port = shell_->GetEngine()->GetUIIsolateMainPort();
617  char* error = NULL;
618  bool success = Dart_WriteProfileToTimeline(main_port, &error);
619  if (!success) {
620  FML_LOG(ERROR) << "Failed to write Dart profile to trace: " << error;
621  free(error);
622  }
623 }
624 #endif // !defined(DART_PRODUCT)
625 
626 } // namespace flutter_runner
static void CreateCompilationTrace(Dart_Isolate isolate)
Definition: engine.cc:431
Engine(Delegate &delegate, std::string thread_label, std::shared_ptr< sys::ServiceDirectory > svc, std::shared_ptr< sys::ServiceDirectory > runner_services, flutter::Settings settings, fml::RefPtr< const flutter::DartSnapshot > isolate_snapshot, fuchsia::ui::views::ViewToken view_token, scenic::ViewRefPair view_ref_pair, UniqueFDIONS fdio_ns, fidl::InterfaceRequest< fuchsia::io::Directory > directory_request, FlutterRunnerProductConfiguration product_config)
Definition: engine.cc:62
std::vector< uint8_t > MakeLocalizationPlatformMessageData(const Profile &intl_profile)
Definition: fuchsia_intl.cc:30
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
Definition: shell.h:99
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition: time_delta.h:49
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define FML_DCHECK(condition)
Definition: logging.h:86
std::function< void(const DartIsolate &)> root_isolate_create_callback
Definition: settings.h:174
DEF_SWITCHES_START snapshot asset Path to the directory containing the four files specified by VmSnapshotInstructions and IsolateSnapshotInstructions vm snapshot The VM instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present isolate snapshot The isolate instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present icu symbol prefix
Definition: switches.h:59
fit::function< std::unique_ptr< flutter::Surface >()> OnCreateSurface
Definition: platform_view.h:31
bool WriteFile(const std::string &path, const char *data, ssize_t size)
Definition: files.cc:69
FlMethodResponse GError ** error
static void RunNowOrPostTask(fml::RefPtr< fml::TaskRunner > runner, const fml::closure &task)
Definition: task_runner.cc:55
Definition: ref_ptr.h:252
fml::RefPtr< fml::TaskRunner > GetPlatformTaskRunner() const
Definition: task_runners.cc:30
virtual void PostTask(const fml::closure &task)
Definition: task_runner.cc:24
#define FML_LOG(severity)
Definition: logging.h:65
fml::RefPtr< fml::TaskRunner > GetRasterTaskRunner() const
Definition: task_runners.cc:42
static DartVMRef Create(Settings settings, fml::RefPtr< DartSnapshot > vm_snapshot=nullptr, fml::RefPtr< DartSnapshot > isolate_snapshot=nullptr)
fit::function< void(int64_t)> OnDestroyView
Definition: platform_view.h:30
MockDelegate delegate_
std::function< void()> closure
Definition: closure.h:14
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
static RunConfiguration InferFromSettings(const Settings &settings, fml::RefPtr< fml::TaskRunner > io_worker=nullptr)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...
fml::closure root_isolate_shutdown_callback
Definition: settings.h:180
fit::function< void(int64_t, bool, bool)> OnUpdateView
Definition: platform_view.h:29
fml::RefPtr< fml::TaskRunner > GetIOTaskRunner() const
Definition: task_runners.cc:38
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
Definition: task_runners.cc:34
virtual void OnEngineTerminate(const Engine *holder)=0
const char * name
Definition: fuchsia.cc:50
#define FML_CHECK(condition)
Definition: logging.h:68
fit::function< void(int64_t, bool, bool)> OnCreateView
Definition: platform_view.h:28
if(event->type==GDK_BUTTON_PRESS)
Definition: fl_view.cc:79
#define FML_DLOG(severity)
Definition: logging.h:85
#define FML_VLOG(verbose_level)
Definition: logging.h:81
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15
fit::function< void(bool)> OnEnableWireframe
Definition: platform_view.h:27
static std::unique_ptr< Shell > Create(TaskRunners task_runners, Settings settings, const CreateCallback< PlatformView > &on_create_platform_view, const CreateCallback< Rasterizer > &on_create_rasterizer)
Creates a shell instance using the provided settings. The callbacks to create the various shell subco...
Definition: shell.cc:239
void WriteProfileToTrace() const
Definition: engine.cc:615
std::optional< uint32_t > GetEngineReturnCode() const
Definition: engine.cc:413