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 "flutter/shell/common/engine.h"
6 
7 #include <memory>
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
12 #include "flutter/common/settings.h"
13 #include "flutter/fml/eintr_wrapper.h"
14 #include "flutter/fml/file.h"
15 #include "flutter/fml/make_copyable.h"
16 #include "flutter/fml/paths.h"
17 #include "flutter/fml/trace_event.h"
18 #include "flutter/fml/unique_fd.h"
19 #include "flutter/lib/snapshot/snapshot.h"
20 #include "flutter/lib/ui/text/font_collection.h"
21 #include "flutter/shell/common/animator.h"
22 #include "flutter/shell/common/platform_view.h"
23 #include "flutter/shell/common/shell.h"
24 #include "rapidjson/document.h"
25 #include "third_party/dart/runtime/include/dart_tools_api.h"
26 #include "third_party/skia/include/core/SkCanvas.h"
27 #include "third_party/skia/include/core/SkPictureRecorder.h"
28 
29 namespace flutter {
30 
31 static constexpr char kAssetChannel[] = "flutter/assets";
32 static constexpr char kLifecycleChannel[] = "flutter/lifecycle";
33 static constexpr char kNavigationChannel[] = "flutter/navigation";
34 static constexpr char kLocalizationChannel[] = "flutter/localization";
35 static constexpr char kSettingsChannel[] = "flutter/settings";
36 static constexpr char kIsolateChannel[] = "flutter/isolate";
37 
39  Delegate& delegate,
40  const PointerDataDispatcherMaker& dispatcher_maker,
41  std::shared_ptr<fml::ConcurrentTaskRunner> image_decoder_task_runner,
42  TaskRunners task_runners,
43  Settings settings,
44  std::unique_ptr<Animator> animator,
45  fml::WeakPtr<IOManager> io_manager,
46  std::unique_ptr<RuntimeController> runtime_controller)
47  : delegate_(delegate),
48  settings_(std::move(settings)),
49  animator_(std::move(animator)),
50  runtime_controller_(std::move(runtime_controller)),
51  activity_running_(true),
52  have_surface_(false),
53  image_decoder_(task_runners, image_decoder_task_runner, io_manager),
54  task_runners_(std::move(task_runners)),
55  weak_factory_(this) {
56  pointer_data_dispatcher_ = dispatcher_maker(*this);
57 }
58 
60  const PointerDataDispatcherMaker& dispatcher_maker,
61  DartVM& vm,
62  fml::RefPtr<const DartSnapshot> isolate_snapshot,
63  TaskRunners task_runners,
64  const PlatformData platform_data,
65  Settings settings,
66  std::unique_ptr<Animator> animator,
67  fml::WeakPtr<IOManager> io_manager,
68  fml::RefPtr<SkiaUnrefQueue> unref_queue,
69  fml::WeakPtr<SnapshotDelegate> snapshot_delegate)
70  : Engine(delegate,
71  dispatcher_maker,
72  vm.GetConcurrentWorkerTaskRunner(),
73  task_runners,
74  settings,
75  std::move(animator),
76  io_manager,
77  nullptr) {
78  runtime_controller_ = std::make_unique<RuntimeController>(
79  *this, // runtime delegate
80  &vm, // VM
81  std::move(isolate_snapshot), // isolate snapshot
82  task_runners_, // task runners
83  std::move(snapshot_delegate), // snapshot delegate
84  GetWeakPtr(), // hint freed delegate
85  std::move(io_manager), // io manager
86  std::move(unref_queue), // Skia unref queue
87  image_decoder_.GetWeakPtr(), // image decoder
88  settings_.advisory_script_uri, // advisory script uri
89  settings_.advisory_script_entrypoint, // advisory script entrypoint
90  settings_.idle_notification_callback, // idle notification callback
91  platform_data, // platform data
92  settings_.isolate_create_callback, // isolate create callback
93  settings_.isolate_shutdown_callback, // isolate shutdown callback
94  settings_.persistent_isolate_data // persistent isolate data
95  );
96 }
97 
98 Engine::~Engine() = default;
99 
101  return weak_factory_.GetWeakPtr();
102 }
103 
105  TRACE_EVENT0("flutter", "Engine::SetupDefaultFontManager");
106  font_collection_.SetupDefaultFontManager();
107 }
108 
109 std::shared_ptr<AssetManager> Engine::GetAssetManager() {
110  return asset_manager_;
111 }
112 
114  std::shared_ptr<AssetManager> new_asset_manager) {
115  if (asset_manager_ == new_asset_manager) {
116  return false;
117  }
118 
119  asset_manager_ = new_asset_manager;
120 
121  if (!asset_manager_) {
122  return false;
123  }
124 
125  // Using libTXT as the text engine.
126  font_collection_.RegisterFonts(asset_manager_);
127 
128  if (settings_.use_test_fonts) {
129  font_collection_.RegisterTestFonts();
130  }
131 
132  return true;
133 }
134 
135 bool Engine::Restart(RunConfiguration configuration) {
136  TRACE_EVENT0("flutter", "Engine::Restart");
137  if (!configuration.IsValid()) {
138  FML_LOG(ERROR) << "Engine run configuration was invalid.";
139  return false;
140  }
141  delegate_.OnPreEngineRestart();
142  runtime_controller_ = runtime_controller_->Clone();
143  UpdateAssetManager(nullptr);
144  return Run(std::move(configuration)) == Engine::RunStatus::Success;
145 }
146 
148  if (!configuration.IsValid()) {
149  FML_LOG(ERROR) << "Engine run configuration was invalid.";
150  return RunStatus::Failure;
151  }
152 
153  last_entry_point_ = configuration.GetEntrypoint();
154  last_entry_point_library_ = configuration.GetEntrypointLibrary();
155 
156  UpdateAssetManager(configuration.GetAssetManager());
157 
158  if (runtime_controller_->IsRootIsolateRunning()) {
160  }
161 
162  if (!runtime_controller_->LaunchRootIsolate(
163  settings_, //
164  configuration.GetEntrypoint(), //
165  configuration.GetEntrypointLibrary(), //
166  configuration.TakeIsolateConfiguration()) //
167  ) {
168  return RunStatus::Failure;
169  }
170 
171  auto service_id = runtime_controller_->GetRootIsolateServiceID();
172  if (service_id.has_value()) {
173  fml::RefPtr<PlatformMessage> service_id_message =
174  fml::MakeRefCounted<flutter::PlatformMessage>(
176  std::vector<uint8_t>(service_id.value().begin(),
177  service_id.value().end()),
178  nullptr);
179  HandlePlatformMessage(service_id_message);
180  }
181 
183 }
184 
186  TRACE_EVENT0("flutter", "Engine::BeginFrame");
187  runtime_controller_->BeginFrame(frame_time);
188 }
189 
190 void Engine::ReportTimings(std::vector<int64_t> timings) {
191  TRACE_EVENT0("flutter", "Engine::ReportTimings");
192  runtime_controller_->ReportTimings(std::move(timings));
193 }
194 
195 void Engine::HintFreed(size_t size) {
196  hint_freed_bytes_since_last_idle_ += size;
197 }
198 
199 void Engine::NotifyIdle(int64_t deadline) {
200  auto trace_event = std::to_string(deadline - Dart_TimelineGetMicros());
201  TRACE_EVENT1("flutter", "Engine::NotifyIdle", "deadline_now_delta",
202  trace_event.c_str());
203  runtime_controller_->NotifyIdle(deadline, hint_freed_bytes_since_last_idle_);
204  hint_freed_bytes_since_last_idle_ = 0;
205 }
206 
207 std::optional<uint32_t> Engine::GetUIIsolateReturnCode() {
208  return runtime_controller_->GetRootIsolateReturnCode();
209 }
210 
212  return runtime_controller_->GetMainPort();
213 }
214 
216  return runtime_controller_->GetIsolateName();
217 }
218 
220  return runtime_controller_->HasLivePorts();
221 }
222 
224  return runtime_controller_->GetLastError();
225 }
226 
228  have_surface_ = true;
229  StartAnimatorIfPossible();
230  ScheduleFrame();
231 }
232 
234  have_surface_ = false;
235  StopAnimator();
236 }
237 
239  bool dimensions_changed =
240  viewport_metrics_.physical_height != metrics.physical_height ||
241  viewport_metrics_.physical_width != metrics.physical_width ||
242  viewport_metrics_.device_pixel_ratio != metrics.device_pixel_ratio;
243  viewport_metrics_ = metrics;
244  runtime_controller_->SetViewportMetrics(viewport_metrics_);
245  if (animator_) {
246  if (dimensions_changed) {
247  animator_->SetDimensionChangePending();
248  }
249  if (have_surface_) {
250  ScheduleFrame();
251  }
252  }
253 }
254 
256  std::string channel = message->channel();
257  if (channel == kLifecycleChannel) {
258  if (HandleLifecyclePlatformMessage(message.get())) {
259  return;
260  }
261  } else if (channel == kLocalizationChannel) {
262  if (HandleLocalizationPlatformMessage(message.get())) {
263  return;
264  }
265  } else if (channel == kSettingsChannel) {
266  HandleSettingsPlatformMessage(message.get());
267  return;
268  } else if (!runtime_controller_->IsRootIsolateRunning() &&
269  channel == kNavigationChannel) {
270  // If there's no runtime_, we may still need to set the initial route.
271  HandleNavigationPlatformMessage(std::move(message));
272  return;
273  }
274 
275  if (runtime_controller_->IsRootIsolateRunning() &&
276  runtime_controller_->DispatchPlatformMessage(std::move(message))) {
277  return;
278  }
279 
280  FML_DLOG(WARNING) << "Dropping platform message on channel: " << channel;
281 }
282 
283 bool Engine::HandleLifecyclePlatformMessage(PlatformMessage* message) {
284  const auto& data = message->data();
285  std::string state(reinterpret_cast<const char*>(data.data()), data.size());
286  if (state == "AppLifecycleState.paused" ||
287  state == "AppLifecycleState.detached") {
288  activity_running_ = false;
289  StopAnimator();
290  } else if (state == "AppLifecycleState.resumed" ||
291  state == "AppLifecycleState.inactive") {
292  activity_running_ = true;
293  StartAnimatorIfPossible();
294  }
295 
296  // Always schedule a frame when the app does become active as per API
297  // recommendation
298  // https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622956-applicationdidbecomeactive?language=objc
299  if (state == "AppLifecycleState.resumed" && have_surface_) {
300  ScheduleFrame();
301  }
302  runtime_controller_->SetLifecycleState(state);
303  // Always forward these messages to the framework by returning false.
304  return false;
305 }
306 
307 bool Engine::HandleNavigationPlatformMessage(
309  const auto& data = message->data();
310 
311  rapidjson::Document document;
312  document.Parse(reinterpret_cast<const char*>(data.data()), data.size());
313  if (document.HasParseError() || !document.IsObject()) {
314  return false;
315  }
316  auto root = document.GetObject();
317  auto method = root.FindMember("method");
318  if (method->value != "setInitialRoute") {
319  return false;
320  }
321  auto route = root.FindMember("args");
322  initial_route_ = std::move(route->value.GetString());
323  return true;
324 }
325 
326 bool Engine::HandleLocalizationPlatformMessage(PlatformMessage* message) {
327  const auto& data = message->data();
328 
329  rapidjson::Document document;
330  document.Parse(reinterpret_cast<const char*>(data.data()), data.size());
331  if (document.HasParseError() || !document.IsObject()) {
332  return false;
333  }
334  auto root = document.GetObject();
335  auto method = root.FindMember("method");
336  if (method == root.MemberEnd()) {
337  return false;
338  }
339  const size_t strings_per_locale = 4;
340  if (method->value == "setLocale") {
341  // Decode and pass the list of locale data onwards to dart.
342  auto args = root.FindMember("args");
343  if (args == root.MemberEnd() || !args->value.IsArray()) {
344  return false;
345  }
346 
347  if (args->value.Size() % strings_per_locale != 0) {
348  return false;
349  }
350  std::vector<std::string> locale_data;
351  for (size_t locale_index = 0; locale_index < args->value.Size();
352  locale_index += strings_per_locale) {
353  if (!args->value[locale_index].IsString() ||
354  !args->value[locale_index + 1].IsString()) {
355  return false;
356  }
357  locale_data.push_back(args->value[locale_index].GetString());
358  locale_data.push_back(args->value[locale_index + 1].GetString());
359  locale_data.push_back(args->value[locale_index + 2].GetString());
360  locale_data.push_back(args->value[locale_index + 3].GetString());
361  }
362 
363  return runtime_controller_->SetLocales(locale_data);
364  }
365  return false;
366 }
367 
368 void Engine::HandleSettingsPlatformMessage(PlatformMessage* message) {
369  const auto& data = message->data();
370  std::string jsonData(reinterpret_cast<const char*>(data.data()), data.size());
371  if (runtime_controller_->SetUserSettingsData(std::move(jsonData)) &&
372  have_surface_) {
373  ScheduleFrame();
374  }
375 }
376 
378  std::unique_ptr<PointerDataPacket> packet,
379  uint64_t trace_flow_id) {
380  TRACE_EVENT0("flutter", "Engine::DispatchPointerDataPacket");
381  TRACE_FLOW_STEP("flutter", "PointerEvent", trace_flow_id);
382  pointer_data_dispatcher_->DispatchPacket(std::move(packet), trace_flow_id);
383 }
384 
387  std::vector<uint8_t> args) {
388  runtime_controller_->DispatchSemanticsAction(id, action, std::move(args));
389 }
390 
391 void Engine::SetSemanticsEnabled(bool enabled) {
392  runtime_controller_->SetSemanticsEnabled(enabled);
393 }
394 
396  runtime_controller_->SetAccessibilityFeatures(flags);
397 }
398 
399 void Engine::StopAnimator() {
400  animator_->Stop();
401 }
402 
403 void Engine::StartAnimatorIfPossible() {
404  if (activity_running_ && have_surface_) {
405  animator_->Start();
406  }
407 }
408 
409 std::string Engine::DefaultRouteName() {
410  if (!initial_route_.empty()) {
411  return initial_route_;
412  }
413  return "/";
414 }
415 
416 void Engine::ScheduleFrame(bool regenerate_layer_tree) {
417  animator_->RequestFrame(regenerate_layer_tree);
418 }
419 
420 void Engine::Render(std::unique_ptr<flutter::LayerTree> layer_tree) {
421  if (!layer_tree) {
422  return;
423  }
424 
425  // Ensure frame dimensions are sane.
426  if (layer_tree->frame_size().isEmpty() ||
427  layer_tree->device_pixel_ratio() <= 0.0f) {
428  return;
429  }
430 
431  animator_->Render(std::move(layer_tree));
432 }
433 
434 void Engine::UpdateSemantics(SemanticsNodeUpdates update,
436  delegate_.OnEngineUpdateSemantics(std::move(update), std::move(actions));
437 }
438 
439 void Engine::HandlePlatformMessage(fml::RefPtr<PlatformMessage> message) {
440  if (message->channel() == kAssetChannel) {
441  HandleAssetPlatformMessage(std::move(message));
442  } else {
443  delegate_.OnEngineHandlePlatformMessage(std::move(message));
444  }
445 }
446 
447 void Engine::OnRootIsolateCreated() {
448  delegate_.OnRootIsolateCreated();
449 }
450 
451 void Engine::UpdateIsolateDescription(const std::string isolate_name,
452  int64_t isolate_port) {
453  delegate_.UpdateIsolateDescription(isolate_name, isolate_port);
454 }
455 
456 std::unique_ptr<std::vector<std::string>> Engine::ComputePlatformResolvedLocale(
457  const std::vector<std::string>& supported_locale_data) {
458  return delegate_.ComputePlatformResolvedLocale(supported_locale_data);
459 }
460 
461 void Engine::SetNeedsReportTimings(bool needs_reporting) {
462  delegate_.SetNeedsReportTimings(needs_reporting);
463 }
464 
466  return font_collection_;
467 }
468 
469 void Engine::DoDispatchPacket(std::unique_ptr<PointerDataPacket> packet,
470  uint64_t trace_flow_id) {
471  animator_->EnqueueTraceFlowId(trace_flow_id);
472  if (runtime_controller_) {
473  runtime_controller_->DispatchPointerDataPacket(*packet);
474  }
475 }
476 
478  animator_->ScheduleSecondaryVsyncCallback(callback);
479 }
480 
481 void Engine::HandleAssetPlatformMessage(fml::RefPtr<PlatformMessage> message) {
482  fml::RefPtr<PlatformMessageResponse> response = message->response();
483  if (!response) {
484  return;
485  }
486  const auto& data = message->data();
487  std::string asset_name(reinterpret_cast<const char*>(data.data()),
488  data.size());
489 
490  if (asset_manager_) {
491  std::unique_ptr<fml::Mapping> asset_mapping =
492  asset_manager_->GetAsMapping(asset_name);
493  if (asset_mapping) {
494  response->Complete(std::move(asset_mapping));
495  return;
496  }
497  }
498 
499  response->CompleteEmpty();
500 }
501 
502 const std::string& Engine::GetLastEntrypoint() const {
503  return last_entry_point_;
504 }
505 
506 const std::string& Engine::GetLastEntrypointLibrary() const {
507  return last_entry_point_library_;
508 }
509 
510 } // namespace flutter
Settings settings_
G_BEGIN_DECLS FlValue * args
bool IsValid() const
A valid run configuration only guarantees that the engine should be able to find the assets and the i...
std::string advisory_script_entrypoint
Definition: settings.h:124
std::shared_ptr< AssetManager > GetAssetManager() const
virtual void OnRootIsolateCreated()=0
Notifies the shell that the root isolate is created. Currently, this information is to add to the ser...
While the engine operates entirely on the UI task runner, it needs the capabilities of the other comp...
Definition: engine.h:139
fml::closure isolate_shutdown_callback
Definition: settings.h:181
Dart_Port GetUIIsolateMainPort()
Gets the main port of the root isolate. Since the isolate is created immediately in the constructor o...
Definition: engine.cc:211
~Engine() override
Destroys the engine engine. Called by the shell on the UI task runner. The running root isolate is te...
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
void DispatchPointerDataPacket(std::unique_ptr< PointerDataPacket > packet, uint64_t trace_flow_id)
Notifies the engine that the embedder has sent it a pointer data packet. A pointer data packet may co...
Definition: engine.cc:377
Engine(Delegate &delegate, const PointerDataDispatcherMaker &dispatcher_maker, std::shared_ptr< fml::ConcurrentTaskRunner > image_decoder_task_runner, TaskRunners task_runners, Settings settings, std::unique_ptr< Animator > animator, fml::WeakPtr< IOManager > io_manager, std::unique_ptr< RuntimeController > runtime_controller)
Creates an instance of the engine with a supplied RuntimeController. Use the other constructor except...
Definition: engine.cc:38
#define TRACE_FLOW_STEP(category, name, id)
Definition: trace_event.h:118
static constexpr char kSettingsChannel[]
Definition: engine.cc:35
std::string advisory_script_uri
Definition: settings.h:121
void BeginFrame(fml::TimePoint frame_time)
Notifies the engine that it is time to begin working on a new frame previously scheduled via a call t...
Definition: engine.cc:185
void ScheduleSecondaryVsyncCallback(const fml::closure &callback) override
Schedule a secondary callback to be executed right after the main VsyncWaiter::AsyncWaitForVsync call...
Definition: engine.cc:477
std::unique_ptr< IsolateConfiguration > TakeIsolateConfiguration()
The engine uses this to take the isolate configuration from the run configuration. The run configuration is no longer valid after this call is made. The non-copyable nature of some of the snapshots referenced in the isolate configuration is why the run configuration as a whole is not copyable.
virtual std::unique_ptr< std::vector< std::string > > ComputePlatformResolvedLocale(const std::vector< std::string > &supported_locale_data)=0
Directly invokes platform-specific APIs to compute the locale the platform would have natively resolv...
void OnOutputSurfaceCreated()
Indicates to the Flutter application that it has obtained a rendering surface. This is a good opportu...
Definition: engine.cc:227
fml::closure isolate_create_callback
Definition: settings.h:177
void SetAccessibilityFeatures(int32_t flags)
Notifies the engine that the embedder has expressed an opinion about where the flags to set on the ac...
Definition: engine.cc:395
tonic::DartErrorHandleType GetUIIsolateLastError()
Errors that are unhandled on the Dart message loop are kept for further inspection till the next unha...
Definition: engine.cc:223
fml::WeakPtr< Engine > GetWeakPtr() const
Definition: engine.cc:100
Definition: ref_ptr.h:252
const std::string & GetEntrypoint() const
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
static constexpr char kIsolateChannel[]
Definition: engine.cc:36
void SetupDefaultFontManager()
Setup default font manager according to specific platform.
Definition: engine.cc:104
#define FML_LOG(severity)
Definition: logging.h:65
virtual void OnPreEngineRestart()=0
Notifies the delegate that the root isolate of the application is about to be discarded and a new iso...
std::function< std::unique_ptr< PointerDataDispatcher >(PointerDataDispatcher::Delegate &)> PointerDataDispatcherMaker
Signature for constructing PointerDataDispatcher.
std::unique_ptr< Animator > animator_
const std::vector< uint8_t > & data() const
bool UpdateAssetManager(std::shared_ptr< AssetManager > asset_manager)
Updates the asset manager referenced by the root isolate of a Flutter application. This happens implicitly in the call to Engine::Run and Engine::Restart as the asset manager is referenced from the run configuration provided to those calls. In addition to the Engine::Run and Engine::Restart calls, the tooling may need to update the assets available to the application as the user adds them to their project. For example, these assets may be referenced by code that is newly patched in after a hot-reload. Neither the shell or the isolate in relaunched in such cases. The tooling usually patches in the new assets in a temporary location and updates the asset manager to point to that location.
Definition: engine.cc:113
std::unique_ptr< RuntimeController > runtime_controller_
const std::string & GetEntrypointLibrary() const
void ScheduleFrame()
Definition: engine.h:737
bool Restart(RunConfiguration configuration)
Tears down an existing root isolate, reuses the components of that isolate and attempts to launch a n...
Definition: engine.cc:135
void RegisterFonts(std::shared_ptr< AssetManager > asset_manager)
DartErrorHandleType
Definition: dart_error.h:18
TaskRunners task_runners_
FontCollection & GetFontCollection() override
Definition: engine.cc:465
MockDelegate delegate_
std::shared_ptr< AssetManager > GetAssetManager()
Definition: engine.cc:109
std::function< void()> closure
Definition: closure.h:14
Specifies all the configuration required by the runtime library to launch the root isolate...
static constexpr char kNavigationChannel[]
Definition: engine.cc:33
virtual void OnEngineUpdateSemantics(SemanticsNodeUpdates updates, CustomAccessibilityActionUpdates actions)=0
When the accessibility tree has been updated by the Flutter application, this new information needs t...
SemanticsAction action
std::optional< uint32_t > GetUIIsolateReturnCode()
As described in the discussion for UIIsolateHasLivePorts, the "done-ness" of a Dart application is tr...
Definition: engine.cc:207
void DispatchSemanticsAction(int id, SemanticsAction action, std::vector< uint8_t > args)
Notifies the engine that the embedder encountered an accessibility related action on the specified no...
Definition: engine.cc:385
void DispatchPlatformMessage(fml::RefPtr< PlatformMessage > message)
Notifies the engine that the embedder has sent it a message. This call originates in the platform vie...
Definition: engine.cc:255
static constexpr char kAssetChannel[]
Definition: engine.cc:31
T * get() const
Definition: ref_ptr.h:112
RunStatus Run(RunConfiguration configuration)
Moves the root isolate to the DartIsolate::Phase::Running phase on a successful call to this method...
Definition: engine.cc:147
virtual void SetNeedsReportTimings(bool needs_reporting)=0
Notifies the shell that the application has an opinion about whether its frame timings need to be rep...
virtual void OnEngineHandlePlatformMessage(fml::RefPtr< PlatformMessage > message)=0
When the Flutter application has a message to send to the underlying platform, the message needs to b...
bool UIIsolateHasLivePorts()
It is an unexpected challenge to determine when a Dart application is "done". The application cannot ...
Definition: engine.cc:219
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
Definition: trace_event.h:79
Describes a running instance of the Dart VM. There may only be one running instance of the Dart VM in...
Definition: dart_vm.h:61
void NotifyIdle(int64_t deadline)
Notifies the engine that the UI task runner is not expected to undertake a new frame workload till a ...
Definition: engine.cc:199
void OnOutputSurfaceDestroyed()
Indicates to the Flutter application that a previously acquired rendering surface has been lost...
Definition: engine.cc:233
void ReportTimings(std::vector< int64_t > timings)
Dart code cannot fully measure the time it takes for a specific frame to be rendered. This is because Dart code only runs on the UI task runner. That is only a small part of the overall frame workload. The GPU task runner frame workload is executed on a thread where Dart code cannot run (and hence instrument). Besides, due to the pipelined nature of rendering in Flutter, there may be multiple frame workloads being processed at any given time. However, for non-Timeline based profiling, it is useful for trace collection and processing to happen in Dart. To do this, the GPU task runner frame workloads need to be instrumented separately. After a set number of these profiles have been gathered, they need to be reported back to Dart code. The shell reports this extra instrumentation information back to Dart code running on the engine by invoking this method at predefined intervals.
Definition: engine.cc:190
#define FML_DLOG(severity)
Definition: logging.h:85
RunStatus
Indicates the result of the call to Engine::Run.
Definition: engine.h:80
std::shared_ptr< const fml::Mapping > persistent_isolate_data
Definition: settings.h:229
static constexpr char kLocalizationChannel[]
Definition: engine.cc:34
void HintFreed(size_t size) override
Notifies the engine that native bytes might be freed if a garbage collection ran at the next NotifyId...
Definition: engine.cc:195
fml::WeakPtr< ImageDecoder > GetWeakPtr() const
const std::string & GetLastEntrypoint() const
Get the last Entrypoint that was used in the RunConfiguration when |Engine::Run| was called...
Definition: engine.cc:502
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
void DoDispatchPacket(std::unique_ptr< PointerDataPacket > packet, uint64_t trace_flow_id) override
Definition: engine.cc:469
const std::string & GetLastEntrypointLibrary() const
Get the last Entrypoint Library that was used in the RunConfiguration when |Engine::Run| was called...
Definition: engine.cc:506
static constexpr char kLifecycleChannel[]
Definition: engine.cc:32
virtual void UpdateIsolateDescription(const std::string isolate_name, int64_t isolate_port)=0
Notifies the shell of the name of the root isolate and its port when that isolate is launched...
void SetSemanticsEnabled(bool enabled)
Notifies the engine that the embedder has expressed an opinion about whether the accessibility tree s...
Definition: engine.cc:391
std::string GetUIIsolateName()
Gets the debug name of the root isolate. But default, the debug name of the isolate is derived from i...
Definition: engine.cc:215
void SetViewportMetrics(const ViewportMetrics &metrics)
Updates the viewport metrics for the currently running Flutter application. The viewport metrics deta...
Definition: engine.cc:238
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 for the symbols representing ICU data linked into the Flutter library dart flags
Definition: switches.h:66
std::function< void(int64_t)> idle_notification_callback
Definition: settings.h:195