未验证 提交 d97b6d85 编写于 作者: C Chinmay Garde 提交者: GitHub

Allow explicit specification of the isolate snapshot. (#5193)

The mobile shells all use the same isolate snapshot. This is also the snapshot used by the service isolate. This works towards a world where the isolate snapshot is no longer a member variable of the DartVM instance. Instead, all snapshots must be specified in the run configuration. For now, the new `Shell::Create` overload will only be used by Fuchsia till I refactor `dart_vm.cc`.

There are no API updates to the mobile shells.
上级 20b286dd
......@@ -21,11 +21,13 @@ namespace blink {
RuntimeController::RuntimeController(
RuntimeDelegate& p_client,
const DartVM* p_vm,
fxl::RefPtr<DartSnapshot> p_isolate_snapshot,
TaskRunners p_task_runners,
fml::WeakPtr<GrContext> p_resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> p_unref_queue)
: RuntimeController(p_client,
p_vm,
std::move(p_isolate_snapshot),
std::move(p_task_runners),
std::move(p_resource_context),
std::move(p_unref_queue),
......@@ -34,19 +36,21 @@ RuntimeController::RuntimeController(
RuntimeController::RuntimeController(
RuntimeDelegate& p_client,
const DartVM* p_vm,
fxl::RefPtr<DartSnapshot> p_isolate_snapshot,
TaskRunners p_task_runners,
fml::WeakPtr<GrContext> p_resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> p_unref_queue,
WindowData p_window_data)
: client_(p_client),
vm_(p_vm),
isolate_snapshot_(std::move(p_isolate_snapshot)),
task_runners_(p_task_runners),
resource_context_(p_resource_context),
unref_queue_(p_unref_queue),
window_data_(std::move(p_window_data)),
root_isolate_(
DartIsolate::CreateRootIsolate(vm_,
vm_->GetIsolateSnapshot(),
isolate_snapshot_,
task_runners_,
std::make_unique<Window>(this),
resource_context_,
......@@ -89,6 +93,7 @@ std::unique_ptr<RuntimeController> RuntimeController::Clone() const {
return std::unique_ptr<RuntimeController>(new RuntimeController(
client_, //
vm_, //
isolate_snapshot_, //
task_runners_, //
resource_context_, //
unref_queue_, //
......
......@@ -25,6 +25,7 @@ class RuntimeController final : public WindowClient {
public:
RuntimeController(RuntimeDelegate& client,
const DartVM* vm,
fxl::RefPtr<DartSnapshot> isolate_snapshot,
TaskRunners task_runners,
fml::WeakPtr<GrContext> resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue);
......@@ -79,6 +80,7 @@ class RuntimeController final : public WindowClient {
RuntimeDelegate& client_;
const DartVM* vm_;
fxl::RefPtr<DartSnapshot> isolate_snapshot_;
TaskRunners task_runners_;
fml::WeakPtr<GrContext> resource_context_;
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue_;
......@@ -88,6 +90,7 @@ class RuntimeController final : public WindowClient {
RuntimeController(RuntimeDelegate& client,
const DartVM* vm,
fxl::RefPtr<DartSnapshot> isolate_snapshot,
TaskRunners task_runners,
fml::WeakPtr<GrContext> resource_context,
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue,
......
......@@ -42,6 +42,7 @@ static constexpr char kSettingsChannel[] = "flutter/settings";
Engine::Engine(Delegate& delegate,
const blink::DartVM& vm,
fxl::RefPtr<blink::DartSnapshot> isolate_snapshot,
blink::TaskRunners task_runners,
blink::Settings settings,
std::unique_ptr<Animator> animator,
......@@ -69,6 +70,7 @@ Engine::Engine(Delegate& delegate,
runtime_controller_ = std::make_unique<blink::RuntimeController>(
*this, // runtime delegate
&vm, // VM
std::move(isolate_snapshot), // isolate snapshot
std::move(task_runners), // task runners
std::move(resource_context), // resource context
std::move(unref_queue) // skia unref queue
......
......@@ -41,6 +41,7 @@ class Engine final : public blink::RuntimeDelegate {
Engine(Delegate& delegate,
const blink::DartVM& vm,
fxl::RefPtr<blink::DartSnapshot> isolate_snapshot,
blink::TaskRunners task_runners,
blink::Settings settings,
std::unique_ptr<Animator> animator,
......
......@@ -38,6 +38,7 @@ namespace shell {
std::unique_ptr<Shell> Shell::CreateShellOnPlatformThread(
blink::TaskRunners task_runners,
blink::Settings settings,
fxl::RefPtr<blink::DartSnapshot> isolate_snapshot,
Shell::CreateCallback<PlatformView> on_create_platform_view,
Shell::CreateCallback<Rasterizer> on_create_rasterizer) {
if (!task_runners.IsValid()) {
......@@ -108,6 +109,7 @@ std::unique_ptr<Shell> Shell::CreateShellOnPlatformThread(
fxl::MakeCopyable([&ui_latch, //
&engine, //
shell = shell.get(), //
isolate_snapshot = std::move(isolate_snapshot), //
vsync_waiter = std::move(vsync_waiter), //
resource_context = std::move(resource_context), //
unref_queue = std::move(unref_queue) //
......@@ -121,6 +123,7 @@ std::unique_ptr<Shell> Shell::CreateShellOnPlatformThread(
engine = std::make_unique<Engine>(*shell, //
shell->GetDartVM(), //
std::move(isolate_snapshot), //
task_runners, //
shell->GetSettings(), //
std::move(animator), //
......@@ -157,6 +160,22 @@ std::unique_ptr<Shell> Shell::Create(
blink::Settings settings,
Shell::CreateCallback<PlatformView> on_create_platform_view,
Shell::CreateCallback<Rasterizer> on_create_rasterizer) {
auto vm = blink::DartVM::ForProcess(settings);
FXL_CHECK(vm) << "Must be able to initialize the VM.";
return Shell::Create(std::move(task_runners), //
std::move(settings), //
vm->GetIsolateSnapshot(), //
std::move(on_create_platform_view), //
std::move(on_create_rasterizer) //
);
}
std::unique_ptr<Shell> Shell::Create(
blink::TaskRunners task_runners,
blink::Settings settings,
fxl::RefPtr<blink::DartSnapshot> isolate_snapshot,
Shell::CreateCallback<PlatformView> on_create_platform_view,
Shell::CreateCallback<Rasterizer> on_create_rasterizer) {
RecordStartupTimestamp();
fxl::LogSettings log_settings;
......@@ -173,11 +192,20 @@ std::unique_ptr<Shell> Shell::Create(
std::unique_ptr<Shell> shell;
fml::TaskRunner::RunNowOrPostTask(
task_runners.GetPlatformTaskRunner(),
[&latch, &shell, task_runners = std::move(task_runners), settings,
on_create_platform_view, on_create_rasterizer]() {
shell = CreateShellOnPlatformThread(std::move(task_runners), settings,
on_create_platform_view,
on_create_rasterizer);
[&latch, //
&shell, //
task_runners = std::move(task_runners), //
settings, //
isolate_snapshot = std::move(isolate_snapshot), //
on_create_platform_view, //
on_create_rasterizer //
]() {
shell = CreateShellOnPlatformThread(std::move(task_runners), //
settings, //
std::move(isolate_snapshot), //
on_create_platform_view, //
on_create_rasterizer //
);
latch.Signal();
});
latch.Wait();
......
......@@ -41,9 +41,21 @@ class Shell final : public PlatformView::Delegate,
public:
template <class T>
using CreateCallback = std::function<std::unique_ptr<T>(Shell&)>;
// Create a shell with the given task runners and settings. The isolate
// snapshot will be shared with the snapshot of the service isolate.
static std::unique_ptr<Shell> Create(
blink::TaskRunners task_runners,
blink::Settings settings,
CreateCallback<PlatformView> on_create_platform_view,
CreateCallback<Rasterizer> on_create_rasterizer);
// Creates a shell with the given task runners and settings. The isolate
// snapshot is specified upfront.
static std::unique_ptr<Shell> Create(
blink::TaskRunners task_runners,
blink::Settings settings,
fxl::RefPtr<blink::DartSnapshot> isolate_snapshot,
CreateCallback<PlatformView> on_create_platform_view,
CreateCallback<Rasterizer> on_create_rasterizer);
......@@ -92,6 +104,7 @@ class Shell final : public PlatformView::Delegate,
static std::unique_ptr<Shell> CreateShellOnPlatformThread(
blink::TaskRunners task_runners,
blink::Settings settings,
fxl::RefPtr<blink::DartSnapshot> isolate_snapshot,
Shell::CreateCallback<PlatformView> on_create_platform_view,
Shell::CreateCallback<Rasterizer> on_create_rasterizer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册