mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
## Description As the related issue refer, the application may be doing too much work on its main thread even in a simple hello_world demo. That is because the creation of `Engine` on the ui thread takes a noticeable time, and it is blocking the platform thread in order to run `Shell::Setup` synchronously. The cost of `Engine`'s constructor is mainly about the creating of root isolate. Actually, there used to be another time-consuming process, the default font manager setup, which was resolved by https://github.com/flutter/engine/pull/18225. Similar to https://github.com/flutter/engine/pull/18225, this pr move the creation of root isolate out from creating `Engine`. After this action, the main thread blocking is quite an acceptable slice. ## Related Issues https://github.com/flutter/flutter/issues/40563 could be resolved by this pr.
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
|
|
#define FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "flutter/flow/layers/layer_tree.h"
|
|
#include "flutter/lib/ui/semantics/custom_accessibility_action.h"
|
|
#include "flutter/lib/ui/semantics/semantics_node.h"
|
|
#include "flutter/lib/ui/text/font_collection.h"
|
|
#include "flutter/lib/ui/window/platform_message.h"
|
|
#include "third_party/dart/runtime/include/dart_api.h"
|
|
|
|
namespace flutter {
|
|
|
|
class RuntimeDelegate {
|
|
public:
|
|
virtual std::string DefaultRouteName() = 0;
|
|
|
|
virtual void ScheduleFrame(bool regenerate_layer_tree = true) = 0;
|
|
|
|
virtual void Render(std::unique_ptr<flutter::LayerTree> layer_tree) = 0;
|
|
|
|
virtual void UpdateSemantics(SemanticsNodeUpdates update,
|
|
CustomAccessibilityActionUpdates actions) = 0;
|
|
|
|
virtual void HandlePlatformMessage(fml::RefPtr<PlatformMessage> message) = 0;
|
|
|
|
virtual FontCollection& GetFontCollection() = 0;
|
|
|
|
virtual void OnRootIsolateCreated() = 0;
|
|
|
|
virtual void UpdateIsolateDescription(const std::string isolate_name,
|
|
int64_t isolate_port) = 0;
|
|
|
|
virtual void SetNeedsReportTimings(bool value) = 0;
|
|
|
|
virtual std::unique_ptr<std::vector<std::string>>
|
|
ComputePlatformResolvedLocale(
|
|
const std::vector<std::string>& supported_locale_data) = 0;
|
|
|
|
protected:
|
|
virtual ~RuntimeDelegate();
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
|