mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
b7d4278b4f
Isolate data may need to be deleted on the same thread where it was allocated. In particular, the task observer set up in the UIDartState ctor must be removed from the same message loop where it was added. The engine had been using the same DartIsolate object as the root isolate data and as the isolate group data. This object would be deleted when the isolate group was shut down. However, group shutdown may occur on a thread associated with a secondary isolate. When this happens, cleanup of any state tied to the root isolate's thread will fail. This change adds a DartIsolateGroupData object holding state that is common among all isolates in a group. DartIsolateGroupData can be deleted on any thread. See https://github.com/flutter/flutter/issues/45578
66 lines
2.0 KiB
C++
66 lines
2.0 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.
|
|
|
|
#include "flutter/runtime/dart_isolate_group_data.h"
|
|
#include "flutter/runtime/dart_snapshot.h"
|
|
|
|
namespace flutter {
|
|
|
|
DartIsolateGroupData::DartIsolateGroupData(
|
|
const Settings& settings,
|
|
fml::RefPtr<const DartSnapshot> isolate_snapshot,
|
|
std::string advisory_script_uri,
|
|
std::string advisory_script_entrypoint,
|
|
const ChildIsolatePreparer& child_isolate_preparer,
|
|
const fml::closure& isolate_create_callback,
|
|
const fml::closure& isolate_shutdown_callback)
|
|
: settings_(settings),
|
|
isolate_snapshot_(isolate_snapshot),
|
|
advisory_script_uri_(advisory_script_uri),
|
|
advisory_script_entrypoint_(advisory_script_entrypoint),
|
|
child_isolate_preparer_(child_isolate_preparer),
|
|
isolate_create_callback_(isolate_create_callback),
|
|
isolate_shutdown_callback_(isolate_shutdown_callback) {
|
|
FML_DCHECK(isolate_snapshot_) << "Must contain a valid isolate snapshot.";
|
|
}
|
|
|
|
DartIsolateGroupData::~DartIsolateGroupData() = default;
|
|
|
|
const Settings& DartIsolateGroupData::GetSettings() const {
|
|
return settings_;
|
|
}
|
|
|
|
fml::RefPtr<const DartSnapshot> DartIsolateGroupData::GetIsolateSnapshot()
|
|
const {
|
|
return isolate_snapshot_;
|
|
}
|
|
|
|
const std::string& DartIsolateGroupData::GetAdvisoryScriptURI() const {
|
|
return advisory_script_uri_;
|
|
}
|
|
|
|
const std::string& DartIsolateGroupData::GetAdvisoryScriptEntrypoint() const {
|
|
return advisory_script_entrypoint_;
|
|
}
|
|
|
|
const ChildIsolatePreparer& DartIsolateGroupData::GetChildIsolatePreparer()
|
|
const {
|
|
return child_isolate_preparer_;
|
|
}
|
|
|
|
const fml::closure& DartIsolateGroupData::GetIsolateCreateCallback() const {
|
|
return isolate_create_callback_;
|
|
}
|
|
|
|
const fml::closure& DartIsolateGroupData::GetIsolateShutdownCallback() const {
|
|
return isolate_shutdown_callback_;
|
|
}
|
|
|
|
void DartIsolateGroupData::SetChildIsolatePreparer(
|
|
const ChildIsolatePreparer& value) {
|
|
child_isolate_preparer_ = value;
|
|
}
|
|
|
|
} // namespace flutter
|