Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
runtime_controller.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/runtime/runtime_controller.h"
6
7#include <utility>
8
9#include "flutter/common/constants.h"
10#include "flutter/common/settings.h"
11#include "flutter/fml/message_loop.h"
12#include "flutter/fml/trace_event.h"
13#include "flutter/lib/ui/compositing/scene.h"
14#include "flutter/lib/ui/ui_dart_state.h"
15#include "flutter/lib/ui/window/platform_configuration.h"
16#include "flutter/lib/ui/window/viewport_metrics.h"
17#include "flutter/runtime/dart_isolate_group_data.h"
18#include "flutter/runtime/isolate_configuration.h"
19#include "flutter/runtime/runtime_delegate.h"
21
22namespace flutter {
23
25 const TaskRunners& task_runners)
26 : client_(p_client), vm_(nullptr), context_(task_runners) {}
27
29 RuntimeDelegate& p_client,
30 DartVM* p_vm,
31 fml::RefPtr<const DartSnapshot> p_isolate_snapshot,
32 const std::function<void(int64_t)>& p_idle_notification_callback,
33 const PlatformData& p_platform_data,
34 const fml::closure& p_isolate_create_callback,
35 const fml::closure& p_isolate_shutdown_callback,
36 std::shared_ptr<const fml::Mapping> p_persistent_isolate_data,
37 const UIDartState::Context& p_context)
38 : client_(p_client),
39 vm_(p_vm),
40 isolate_snapshot_(std::move(p_isolate_snapshot)),
41 idle_notification_callback_(p_idle_notification_callback),
42 platform_data_(p_platform_data),
43 isolate_create_callback_(p_isolate_create_callback),
44 isolate_shutdown_callback_(p_isolate_shutdown_callback),
45 persistent_isolate_data_(std::move(p_persistent_isolate_data)),
46 context_(p_context) {}
47
48std::unique_ptr<RuntimeController> RuntimeController::Spawn(
49 RuntimeDelegate& p_client,
50 const std::string& advisory_script_uri,
51 const std::string& advisory_script_entrypoint,
52 const std::function<void(int64_t)>& p_idle_notification_callback,
53 const fml::closure& p_isolate_create_callback,
54 const fml::closure& p_isolate_shutdown_callback,
55 const std::shared_ptr<const fml::Mapping>& p_persistent_isolate_data,
56 fml::WeakPtr<IOManager> io_manager,
57 fml::WeakPtr<ImageDecoder> image_decoder,
58 fml::WeakPtr<ImageGeneratorRegistry> image_generator_registry,
59 fml::TaskRunnerAffineWeakPtr<SnapshotDelegate> snapshot_delegate) const {
60 UIDartState::Context spawned_context{context_.task_runners,
61 std::move(snapshot_delegate),
62 std::move(io_manager),
63 context_.unref_queue,
64 std::move(image_decoder),
65 std::move(image_generator_registry),
66 advisory_script_uri,
67 advisory_script_entrypoint,
68 context_.volatile_path_tracker,
70 context_.enable_impeller,
71 context_.runtime_stage_backend};
72 auto result =
73 std::make_unique<RuntimeController>(p_client, //
74 vm_, //
75 isolate_snapshot_, //
76 p_idle_notification_callback, //
77 platform_data_, //
78 p_isolate_create_callback, //
79 p_isolate_shutdown_callback, //
80 p_persistent_isolate_data, //
81 spawned_context); //
82 result->spawning_isolate_ = root_isolate_;
83 return result;
84}
85
87 FML_DCHECK(Dart_CurrentIsolate() == nullptr);
88 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
89 if (root_isolate) {
90 root_isolate->SetReturnCodeCallback(nullptr);
91 auto result = root_isolate->Shutdown();
92 if (!result) {
93 FML_DLOG(ERROR) << "Could not shutdown the root isolate.";
94 }
95 root_isolate_ = {};
96 }
97}
98
100 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
101 if (root_isolate) {
102 return root_isolate->GetPhase() == DartIsolate::Phase::Running;
103 }
104 return false;
105}
106
107std::unique_ptr<RuntimeController> RuntimeController::Clone() const {
108 return std::make_unique<RuntimeController>(client_, //
109 vm_, //
110 isolate_snapshot_, //
111 idle_notification_callback_, //
112 platform_data_, //
113 isolate_create_callback_, //
114 isolate_shutdown_callback_, //
115 persistent_isolate_data_, //
116 context_ //
117 );
118}
119
120bool RuntimeController::FlushRuntimeStateToIsolate() {
121 FML_DCHECK(!has_flushed_runtime_state_)
122 << "FlushRuntimeStateToIsolate is called more than once somehow.";
123 has_flushed_runtime_state_ = true;
124
125 auto platform_configuration = GetPlatformConfigurationIfAvailable();
126 if (!platform_configuration) {
127 return false;
128 }
129
130 for (auto const& [view_id, viewport_metrics] :
131 platform_data_.viewport_metrics_for_views) {
132 bool added = platform_configuration->AddView(view_id, viewport_metrics);
133
134 // Callbacks will have been already invoked if the engine was restarted.
135 if (pending_add_view_callbacks_.find(view_id) !=
136 pending_add_view_callbacks_.end()) {
137 pending_add_view_callbacks_[view_id](added);
138 pending_add_view_callbacks_.erase(view_id);
139 }
140
141 if (!added) {
142 FML_LOG(ERROR) << "Failed to flush view #" << view_id
143 << ". The Dart isolate may be in an inconsistent state.";
144 }
145 }
146
147 FML_DCHECK(pending_add_view_callbacks_.empty());
148 return SetLocales(platform_data_.locale_data) &&
149 SetSemanticsEnabled(platform_data_.semantics_enabled) &&
151 platform_data_.accessibility_feature_flags_) &&
152 SetUserSettingsData(platform_data_.user_settings_data) &&
154 SetDisplays(platform_data_.displays);
155}
156
157void RuntimeController::AddView(int64_t view_id,
158 const ViewportMetrics& view_metrics,
160 // If the Dart isolate is not running, |FlushRuntimeStateToIsolate| will
161 // add the view and invoke the callback when the isolate is started.
162 auto* platform_configuration = GetPlatformConfigurationIfAvailable();
163 if (!platform_configuration) {
164 FML_DCHECK(has_flushed_runtime_state_ == false);
165
166 if (pending_add_view_callbacks_.find(view_id) !=
167 pending_add_view_callbacks_.end()) {
168 FML_LOG(ERROR) << "View #" << view_id << " is already pending creation.";
169 callback(false);
170 return;
171 }
172
173 platform_data_.viewport_metrics_for_views[view_id] = view_metrics;
174 pending_add_view_callbacks_[view_id] = std::move(callback);
175 return;
176 }
177
178 FML_DCHECK(has_flushed_runtime_state_ || pending_add_view_callbacks_.empty());
179
180 platform_data_.viewport_metrics_for_views[view_id] = view_metrics;
181 bool added = platform_configuration->AddView(view_id, view_metrics);
182 if (added) {
184 }
185
186 callback(added);
187}
188
189bool RuntimeController::RemoveView(int64_t view_id) {
190 platform_data_.viewport_metrics_for_views.erase(view_id);
191
192 // If the Dart isolate has not been launched yet, the pending
193 // add view operation's callback is stored by the runtime controller.
194 // Notify this callback of the cancellation.
195 auto* platform_configuration = GetPlatformConfigurationIfAvailable();
196 if (!platform_configuration) {
197 FML_DCHECK(has_flushed_runtime_state_ == false);
198 if (pending_add_view_callbacks_.find(view_id) !=
199 pending_add_view_callbacks_.end()) {
200 pending_add_view_callbacks_[view_id](false);
201 pending_add_view_callbacks_.erase(view_id);
202 }
203
204 return false;
205 }
206
207 return platform_configuration->RemoveView(view_id);
208}
209
211 const ViewportMetrics& metrics) {
212 TRACE_EVENT0("flutter", "SetViewportMetrics");
213
214 platform_data_.viewport_metrics_for_views[view_id] = metrics;
215 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
216 return platform_configuration->UpdateViewMetrics(view_id, metrics);
217 }
218
219 return false;
220}
221
223 const std::vector<std::string>& locale_data) {
224 platform_data_.locale_data = locale_data;
225
226 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
227 platform_configuration->UpdateLocales(locale_data);
228 return true;
229 }
230
231 return false;
232}
233
235 platform_data_.user_settings_data = data;
236
237 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
238 platform_configuration->UpdateUserSettingsData(
239 platform_data_.user_settings_data);
240 return true;
241 }
242
243 return false;
244}
245
247 platform_data_.lifecycle_state = data;
248
249 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
250 platform_configuration->UpdateInitialLifecycleState(
251 platform_data_.lifecycle_state);
252 return true;
253 }
254
255 return false;
256}
257
259 platform_data_.semantics_enabled = enabled;
260
261 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
262 platform_configuration->UpdateSemanticsEnabled(
263 platform_data_.semantics_enabled);
264 return true;
265 }
266
267 return false;
268}
269
271 platform_data_.accessibility_feature_flags_ = flags;
272 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
273 platform_configuration->UpdateAccessibilityFeatures(
274 platform_data_.accessibility_feature_flags_);
275 return true;
276 }
277
278 return false;
279}
280
282 uint64_t frame_number) {
283 MarkAsFrameBorder();
284 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
285 platform_configuration->BeginFrame(frame_time, frame_number);
286 return true;
287 }
288
289 return false;
290}
291
292bool RuntimeController::ReportTimings(std::vector<int64_t> timings) {
293 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
294 platform_configuration->ReportTimings(std::move(timings));
295 return true;
296 }
297
298 return false;
299}
300
304 // There's less than 1ms left before the deadline. Upstream callers do not
305 // check to see if the deadline is in the past, and work after this point
306 // will be in vain.
307 return false;
308 }
309
310 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
311 if (!root_isolate) {
312 return false;
313 }
314
315 tonic::DartState::Scope scope(root_isolate);
316
317 Dart_PerformanceMode performance_mode =
320 return false;
321 }
322
324
325 // Idle notifications being in isolate scope are part of the contract.
326 if (idle_notification_callback_) {
327 TRACE_EVENT0("flutter", "EmbedderIdleNotification");
328 idle_notification_callback_(deadline.ToMicroseconds());
329 }
330 return true;
331}
332
334 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
335 if (!root_isolate) {
336 return false;
337 }
338
339 tonic::DartState::Scope scope(root_isolate);
340
342
343 return true;
344}
345
347 std::unique_ptr<PlatformMessage> message) {
348 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
349 TRACE_EVENT0("flutter", "RuntimeController::DispatchPlatformMessage");
350 platform_configuration->DispatchPlatformMessage(std::move(message));
351 return true;
352 }
353
354 return false;
355}
356
358 const PointerDataPacket& packet) {
359 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
360 TRACE_EVENT0("flutter", "RuntimeController::DispatchPointerDataPacket");
361 platform_configuration->DispatchPointerDataPacket(packet);
362 return true;
363 }
364
365 return false;
366}
367
371 TRACE_EVENT1("flutter", "RuntimeController::DispatchSemanticsAction", "mode",
372 "basic");
373 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
374 platform_configuration->DispatchSemanticsAction(node_id, action,
375 std::move(args));
376 return true;
377 }
378
379 return false;
380}
381
383RuntimeController::GetPlatformConfigurationIfAvailable() {
384 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
385 return root_isolate ? root_isolate->platform_configuration() : nullptr;
386}
387
388// |PlatformConfigurationClient|
390 return client_.DefaultRouteName();
391}
392
393// |PlatformConfigurationClient|
397
401
402// |PlatformConfigurationClient|
403void RuntimeController::Render(int64_t view_id,
404 Scene* scene,
405 double width,
406 double height) {
407 const ViewportMetrics* view_metrics =
409 if (view_metrics == nullptr) {
410 return;
411 }
412 client_.Render(view_id, scene->takeLayerTree(width, height),
413 view_metrics->device_pixel_ratio);
414 rendered_views_during_frame_.insert(view_id);
415 CheckIfAllViewsRendered();
416}
417
418void RuntimeController::MarkAsFrameBorder() {
419 rendered_views_during_frame_.clear();
420}
421
422void RuntimeController::CheckIfAllViewsRendered() {
423 if (rendered_views_during_frame_.size() != 0 &&
424 rendered_views_during_frame_.size() ==
425 platform_data_.viewport_metrics_for_views.size()) {
426 client_.OnAllViewsRendered();
427 MarkAsFrameBorder();
428 }
429}
430
431// |PlatformConfigurationClient|
433 if (platform_data_.semantics_enabled) {
434 client_.UpdateSemantics(update->takeNodes(), update->takeActions());
435 }
436}
437
438// |PlatformConfigurationClient|
440 std::unique_ptr<PlatformMessage> message) {
441 client_.HandlePlatformMessage(std::move(message));
442}
443
444// |PlatformConfigurationClient|
448
449// |PlatfromConfigurationClient|
450std::shared_ptr<AssetManager> RuntimeController::GetAssetManager() {
451 return client_.GetAssetManager();
452}
453
454// |PlatformConfigurationClient|
455void RuntimeController::UpdateIsolateDescription(const std::string isolate_name,
456 int64_t isolate_port) {
457 client_.UpdateIsolateDescription(isolate_name, isolate_port);
458}
459
460// |PlatformConfigurationClient|
464
465// |PlatformConfigurationClient|
466std::shared_ptr<const fml::Mapping>
468 return persistent_isolate_data_;
469}
470
471// |PlatformConfigurationClient|
472std::unique_ptr<std::vector<std::string>>
474 const std::vector<std::string>& supported_locale_data) {
475 return client_.ComputePlatformResolvedLocale(supported_locale_data);
476}
477
478// |PlatformConfigurationClient|
479void RuntimeController::SendChannelUpdate(std::string name, bool listening) {
480 client_.SendChannelUpdate(std::move(name), listening);
481}
482
484 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
485 return root_isolate ? root_isolate->main_port() : ILLEGAL_PORT;
486}
487
489 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
490 return root_isolate ? root_isolate->debug_name() : "";
491}
492
494 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
495 if (!root_isolate) {
496 return false;
497 }
498 tonic::DartState::Scope scope(root_isolate);
499 return Dart_HasLivePorts();
500}
501
503 std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
504 return root_isolate ? root_isolate->GetLastError() : tonic::kNoError;
505}
506
508 const Settings& settings,
509 const fml::closure& root_isolate_create_callback,
510 std::optional<std::string> dart_entrypoint,
511 std::optional<std::string> dart_entrypoint_library,
512 const std::vector<std::string>& dart_entrypoint_args,
513 std::unique_ptr<IsolateConfiguration> isolate_configuration) {
514 if (root_isolate_.lock()) {
515 FML_LOG(ERROR) << "Root isolate was already running.";
516 return false;
517 }
518
519 auto strong_root_isolate =
521 settings, //
522 isolate_snapshot_, //
523 std::make_unique<PlatformConfiguration>(this), //
525 root_isolate_create_callback, //
526 isolate_create_callback_, //
527 isolate_shutdown_callback_, //
528 std::move(dart_entrypoint), //
529 std::move(dart_entrypoint_library), //
530 dart_entrypoint_args, //
531 std::move(isolate_configuration), //
532 context_, //
533 spawning_isolate_.lock().get()) //
534 .lock();
535
536 if (!strong_root_isolate) {
537 FML_LOG(ERROR) << "Could not create root isolate.";
538 return false;
539 }
540
541 // Enable platform channels for background isolates.
542 strong_root_isolate->GetIsolateGroupData().SetPlatformMessageHandler(
543 strong_root_isolate->GetRootIsolateToken(),
544 client_.GetPlatformMessageHandler());
545
546 // The root isolate ivar is weak.
547 root_isolate_ = strong_root_isolate;
548
549 // Capture by `this` here is safe because the callback is made by the dart
550 // state itself. The isolate (and its Dart state) is owned by this object and
551 // it will be collected before this object.
552 strong_root_isolate->SetReturnCodeCallback(
553 [this](uint32_t code) { root_isolate_return_code_ = code; });
554
555 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
556 tonic::DartState::Scope scope(strong_root_isolate);
557 platform_configuration->DidCreateIsolate();
558 if (!FlushRuntimeStateToIsolate()) {
559 FML_DLOG(ERROR) << "Could not set up initial isolate state.";
560 }
561 } else {
562 FML_DCHECK(false) << "RuntimeController created without window binding.";
563 }
564
565 FML_DCHECK(Dart_CurrentIsolate() == nullptr);
566
567 client_.OnRootIsolateCreated();
568
569 return true;
570}
571
572std::optional<std::string> RuntimeController::GetRootIsolateServiceID() const {
573 if (auto isolate = root_isolate_.lock()) {
574 return isolate->GetServiceId();
575 }
576 return std::nullopt;
577}
578
580 return root_isolate_return_code_;
581}
582
584 auto isolate = root_isolate_.lock();
585 if (isolate) {
586 auto isolate_scope = tonic::DartIsolateScope(isolate->isolate());
588 return reinterpret_cast<uint64_t>(isolate_group);
589 } else {
590 return 0;
591 }
592}
593
595 intptr_t loading_unit_id,
596 std::unique_ptr<const fml::Mapping> snapshot_data,
597 std::unique_ptr<const fml::Mapping> snapshot_instructions) {
598 root_isolate_.lock()->LoadLoadingUnit(loading_unit_id,
599 std::move(snapshot_data),
600 std::move(snapshot_instructions));
601}
602
604 intptr_t loading_unit_id,
605 const std::string
606 error_message, // NOLINT(performance-unnecessary-value-param)
607 bool transient) {
608 root_isolate_.lock()->LoadLoadingUnitError(loading_unit_id, error_message,
609 transient);
610}
611
612void RuntimeController::RequestDartDeferredLibrary(intptr_t loading_unit_id) {
613 return client_.RequestDartDeferredLibrary(loading_unit_id);
614}
615
616bool RuntimeController::SetDisplays(const std::vector<DisplayData>& displays) {
617 TRACE_EVENT0("flutter", "SetDisplays");
618 platform_data_.displays = displays;
619
620 if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
621 platform_configuration->UpdateDisplays(displays);
622 return true;
623 }
624 return false;
625}
626
627double RuntimeController::GetScaledFontSize(double unscaled_font_size,
628 int configuration_id) const {
629 return client_.GetScaledFontSize(unscaled_font_size, configuration_id);
630}
631
633 platform_isolate_manager_->ShutdownPlatformIsolates();
634}
635
636RuntimeController::Locale::Locale(std::string language_code_,
637 std::string country_code_,
638 std::string script_code_,
639 std::string variant_code_)
640 : language_code(std::move(language_code_)),
641 country_code(std::move(country_code_)),
642 script_code(std::move(script_code_)),
643 variant_code(std::move(variant_code_)) {}
644
645RuntimeController::Locale::~Locale() = default;
646
647} // namespace flutter
static std::weak_ptr< DartIsolate > CreateRunningRootIsolate(const Settings &settings, const fml::RefPtr< const DartSnapshot > &isolate_snapshot, std::unique_ptr< PlatformConfiguration > platform_configuration, Flags flags, const fml::closure &root_isolate_create_callback, const fml::closure &isolate_create_callback, const fml::closure &isolate_shutdown_callback, std::optional< std::string > dart_entrypoint, std::optional< std::string > dart_entrypoint_library, const std::vector< std::string > &dart_entrypoint_args, std::unique_ptr< IsolateConfiguration > isolate_configuration, const UIDartState::Context &context, const DartIsolate *spawning_isolate=nullptr)
Creates an instance of a root isolate and returns a weak pointer to the same. The isolate instance ma...
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
static Dart_PerformanceMode GetDartPerformanceMode()
Returns the current performance mode of the Dart VM. Defaults to Dart_PerformanceMode_Default if no p...
A class for holding and distributing platform-level information to and from the Dart code in Flutter'...
const ViewportMetrics * GetMetrics(int view_id)
Retrieves the viewport metrics with the given ID managed by the PlatformConfiguration.
void AddView(int64_t view_id, const ViewportMetrics &view_metrics, AddViewCallback callback)
Notify the isolate that a new view is available.
bool SetAccessibilityFeatures(int32_t flags)
Forward the preference of accessibility features that must be enabled in the semantics tree to the ru...
virtual bool IsRootIsolateRunning()
Returns if the root isolate is running. The isolate must be transitioned to the running phase manuall...
Dart_Port GetMainPort()
Gets the main port identifier of the root isolate.
bool SetSemanticsEnabled(bool enabled)
Notifies the running isolate about whether the semantics tree should be generated or not....
bool SetViewportMetrics(int64_t view_id, const ViewportMetrics &metrics)
Forward the specified viewport metrics to the running isolate. If the isolate is not running,...
uint64_t GetRootIsolateGroup() const
Get an identifier that represents the Dart isolate group the root isolate is in.
RuntimeController(RuntimeDelegate &p_client, DartVM *vm, fml::RefPtr< const DartSnapshot > p_isolate_snapshot, const std::function< void(int64_t)> &idle_notification_callback, const PlatformData &platform_data, const fml::closure &isolate_create_callback, const fml::closure &isolate_shutdown_callback, std::shared_ptr< const fml::Mapping > p_persistent_isolate_data, const UIDartState::Context &context)
Creates a new instance of a runtime controller. This is usually only done by the engine instance asso...
void UpdateIsolateDescription(const std::string isolate_name, int64_t isolate_port) override
Notifies this client of the name of the root isolate and its port when that isolate is launched,...
bool DispatchSemanticsAction(int32_t node_id, SemanticsAction action, fml::MallocMapping args)
Dispatch the semantics action to the specified accessibility node.
virtual bool NotifyIdle(fml::TimeDelta deadline)
Notify the Dart VM that no frame workloads are expected on the UI task runner till the specified dead...
void ScheduleFrame() override
Requests that, at the next appropriate opportunity, a new frame be scheduled for rendering.
bool DispatchPointerDataPacket(const PointerDataPacket &packet)
Dispatch the specified pointer data message to the running root isolate.
bool SetInitialLifecycleState(const std::string &data)
Forward the initial lifecycle state data to the running isolate. If the isolate is not running,...
std::function< void(bool added)> AddViewCallback
void Render(int64_t view_id, Scene *scene, double width, double height) override
Updates the client's rendering on the GPU with the newly provided Scene.
bool SetLocales(const std::vector< std::string > &locale_data)
Forward the specified locale data to the running isolate. If the isolate is not running,...
void RequestDartDeferredLibrary(intptr_t loading_unit_id) override
Invoked when the Dart VM requests that a deferred library be loaded. Notifies the engine that the def...
bool SetDisplays(const std::vector< DisplayData > &displays)
Forward the specified display metrics to the running isolate. If the isolate is not running,...
bool HasLivePorts()
Returns if the root isolate has any live receive ports.
void EndWarmUpFrame() override
Called when a warm up frame has ended.
void SendChannelUpdate(std::string name, bool listening) override
Invoked when a listener is registered on a platform channel.
bool RemoveView(int64_t view_id)
Notify the isolate that a view is no longer available.
std::optional< std::string > GetRootIsolateServiceID() const
Get the service ID of the root isolate if the root isolate is running.
void HandlePlatformMessage(std::unique_ptr< PlatformMessage > message) override
When the Flutter application has a message to send to the underlying platform, the message needs to b...
std::shared_ptr< AssetManager > GetAssetManager() override
Returns the current collection of assets available on the platform.
double GetScaledFontSize(double unscaled_font_size, int configuration_id) const override
Synchronously invokes platform-specific APIs to apply the system text scaling on the given unscaled f...
std::string DefaultRouteName() override
The route or path that the embedder requested when the application was launched.
std::unique_ptr< RuntimeController > Spawn(RuntimeDelegate &p_client, const std::string &advisory_script_uri, const std::string &advisory_script_entrypoint, const std::function< void(int64_t)> &idle_notification_callback, const fml::closure &isolate_create_callback, const fml::closure &isolate_shutdown_callback, const std::shared_ptr< const fml::Mapping > &persistent_isolate_data, fml::WeakPtr< IOManager > io_manager, fml::WeakPtr< ImageDecoder > image_decoder, fml::WeakPtr< ImageGeneratorRegistry > image_generator_registry, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate) const
Create a RuntimeController that shares as many resources as possible with the calling RuntimeControll...
bool ReportTimings(std::vector< int64_t > timings)
Dart code cannot fully measure the time it takes for a specific frame to be rendered....
virtual bool NotifyDestroyed()
Notify the Dart VM that the attached flutter view has been destroyed. This gives the Dart VM to perfo...
void UpdateSemantics(SemanticsUpdate *update) override
Receives an updated semantics tree from the Framework.
bool LaunchRootIsolate(const Settings &settings, const fml::closure &root_isolate_create_callback, std::optional< std::string > dart_entrypoint, std::optional< std::string > dart_entrypoint_library, const std::vector< std::string > &dart_entrypoint_args, std::unique_ptr< IsolateConfiguration > isolate_configuration)
Launches the isolate using the window data associated with this runtime controller....
void SetNeedsReportTimings(bool value) override
Notifies this client that the application has an opinion about whether its frame timings need to be r...
virtual bool DispatchPlatformMessage(std::unique_ptr< PlatformMessage > message)
Dispatch the specified platform message to running root isolate.
tonic::DartErrorHandleType GetLastError()
Get the last error encountered by the microtask queue.
bool SetUserSettingsData(const std::string &data)
Forward the user settings data to the running isolate. If the isolate is not running,...
void LoadDartDeferredLibrary(intptr_t loading_unit_id, std::unique_ptr< const fml::Mapping > snapshot_data, std::unique_ptr< const fml::Mapping > snapshot_instructions)
Loads the Dart shared library into the Dart VM. When the Dart library is loaded successfully,...
std::unique_ptr< RuntimeController > Clone() const
Clone the runtime controller. Launching an isolate with a cloned runtime controller will use the same...
FontCollection & GetFontCollection() override
Returns the current collection of fonts available on the platform.
void ShutdownPlatformIsolates()
Shuts down all registered platform isolates. Must be called from the platform thread.
bool BeginFrame(fml::TimePoint frame_time, uint64_t frame_number)
Notifies the running isolate that it should start generating a new frame.
std::optional< uint32_t > GetRootIsolateReturnCode()
Get the return code specified by the root isolate (if one is present).
std::shared_ptr< const fml::Mapping > GetPersistentIsolateData() override
The embedder can specify data that the isolate can request synchronously on launch....
std::unique_ptr< std::vector< std::string > > ComputePlatformResolvedLocale(const std::vector< std::string > &supported_locale_data) override
Directly invokes platform-specific APIs to compute the locale the platform would have natively resolv...
virtual void LoadDartDeferredLibraryError(intptr_t loading_unit_id, const std::string error_message, bool transient)
Indicates to the dart VM that the request to load a deferred library with the specified loading unit ...
std::string GetIsolateName()
Gets the debug name of the root isolate. But default, the debug name of the isolate is derived from i...
virtual std::unique_ptr< std::vector< std::string > > ComputePlatformResolvedLocale(const std::vector< std::string > &supported_locale_data)=0
virtual void RequestDartDeferredLibrary(intptr_t loading_unit_id)=0
virtual double GetScaledFontSize(double unscaled_font_size, int configuration_id) const =0
virtual std::string DefaultRouteName()=0
virtual std::weak_ptr< PlatformMessageHandler > GetPlatformMessageHandler() const =0
virtual void HandlePlatformMessage(std::unique_ptr< PlatformMessage > message)=0
virtual void SetNeedsReportTimings(bool value)=0
virtual void UpdateSemantics(SemanticsNodeUpdates update, CustomAccessibilityActionUpdates actions)=0
virtual std::shared_ptr< AssetManager > GetAssetManager()=0
virtual void OnRootIsolateCreated()=0
virtual FontCollection & GetFontCollection()=0
virtual void Render(int64_t view_id, std::unique_ptr< flutter::LayerTree > layer_tree, float device_pixel_ratio)=0
virtual void UpdateIsolateDescription(const std::string isolate_name, int64_t isolate_port)=0
virtual void OnAllViewsRendered()=0
virtual void SendChannelUpdate(std::string name, bool listening)=0
virtual void ScheduleFrame(bool regenerate_layer_trees=true)=0
std::unique_ptr< flutter::LayerTree > takeLayerTree(uint64_t width, uint64_t height)
Definition scene.cc:130
PlatformConfiguration * platform_configuration() const
static UIDartState * Current()
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144
constexpr int64_t ToMicroseconds() const
Definition time_delta.h:62
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition time_delta.h:46
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition time_delta.h:43
#define ILLEGAL_PORT
Definition dart_api.h:1530
Dart_PerformanceMode
Definition dart_api.h:1368
@ Dart_PerformanceMode_Latency
Definition dart_api.h:1379
int64_t Dart_Port
Definition dart_api.h:1524
struct _Dart_IsolateGroup * Dart_IsolateGroup
Definition dart_api.h:89
DART_EXPORT void Dart_NotifyIdle(int64_t deadline)
DART_EXPORT Dart_Isolate Dart_CurrentIsolate(void)
DART_EXPORT void Dart_NotifyDestroyed(void)
DART_EXPORT Dart_IsolateGroup Dart_CurrentIsolateGroup(void)
DART_EXPORT bool Dart_HasLivePorts(void)
DART_EXPORT int64_t Dart_TimelineGetMicros()
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint8_t value
GAsyncResult * result
#define FML_DLOG(severity)
Definition logging.h:102
#define FML_LOG(severity)
Definition logging.h:82
#define FML_DCHECK(condition)
Definition logging.h:103
Win32Message message
DEF_SWITCHES_START aot vmservice shared library name
Definition switches.h:32
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
std::function< void()> closure
Definition closure.h:14
Definition ref_ptr.h:256
DartErrorHandleType
Definition dart_error.h:67
@ kNoError
Definition dart_error.h:68
int32_t height
int32_t width
std::unordered_map< int64_t, ViewportMetrics > viewport_metrics_for_views
int32_t accessibility_feature_flags_
std::string lifecycle_state
std::vector< DisplayData > displays
std::vector< std::string > locale_data
std::string user_settings_data
The subset of state which is owned by the shell or engine and passed through the RuntimeController in...
fml::RefPtr< SkiaUnrefQueue > unref_queue
const TaskRunners task_runners
std::shared_ptr< VolatilePathTracker > volatile_path_tracker
Cache for tracking path volatility.
bool enable_impeller
Whether Impeller is enabled or not.
impeller::RuntimeStageBackend runtime_stage_backend
The expected backend for runtime stage shaders.
std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner
#define ERROR(message)
#define TRACE_EVENT0(category_group, name)
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)