Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ffa089e

Browse files
committed
WeakPersistentHandle migration
1 parent 9f9fc1f commit ffa089e

20 files changed

+477
-42
lines changed

BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ group("flutter") {
9898
"//flutter/shell/platform/embedder:embedder_proctable_unittests",
9999
"//flutter/shell/platform/embedder:embedder_unittests",
100100
"//flutter/testing:testing_unittests",
101+
"//flutter/third_party/tonic/tests:tonic_unittests",
101102
"//flutter/third_party/txt:txt_unittests",
102103
]
103104

DEPS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ vars = {
3434
# Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS.
3535
# You can use //tools/dart/create_updated_flutter_deps.py to produce
3636
# updated revision list of existing dependencies.
37-
'dart_revision': 'fed66f60a3bc0f708b299a682f7bbe5673f85d55',
37+
'dart_revision': '7f6e565f30c1cc7b3d87bf0c257f2088569deef5',
3838

3939
# WARNING: DO NOT EDIT MANUALLY
4040
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py
@@ -155,7 +155,7 @@ deps = {
155155
'https://boringssl.googlesource.com/boringssl.git' + '@' + Var('dart_boringssl_rev'),
156156

157157
'src/third_party/dart':
158-
Var('dart_git') + '/sdk.git' + '@' + Var('dart_revision'),
158+
'https://github.com/dart-lang/sdk.git' + '@' + Var('dart_revision'),
159159

160160
# WARNING: Unused Dart dependencies in the list below till "WARNING:" marker are removed automatically - see create_updated_flutter_deps.py.
161161

lib/ui/painting/image_decoder.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,13 @@ void ImageDecoder::Decode(fml::RefPtr<ImageDescriptor> descriptor,
224224
FML_DCHECK(callback);
225225
FML_DCHECK(runners_.GetUITaskRunner()->RunsTasksOnCurrentThread());
226226

227-
// Always service the callback on the UI thread.
228-
auto result = [callback, ui_runner = runners_.GetUITaskRunner()](
227+
// Always service the callback (and cleanup the descriptor) on the UI thread.
228+
auto result = [callback, descriptor, ui_runner = runners_.GetUITaskRunner()](
229229
SkiaGPUObject<SkImage> image,
230230
fml::tracing::TraceFlow flow) {
231-
ui_runner->PostTask(fml::MakeCopyable(
232-
[callback, image = std::move(image), flow = std::move(flow)]() mutable {
231+
ui_runner->PostTask(
232+
fml::MakeCopyable([callback, descriptor, image = std::move(image),
233+
flow = std::move(flow)]() mutable {
233234
// We are going to terminate the trace flow here. Flows cannot
234235
// terminate without a base trace. Add one explicitly.
235236
TRACE_EVENT0("flutter", "ImageDecodeCallback");

lib/ui/painting/image_encoding.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ enum ImageByteFormat {
3535
kPNG,
3636
};
3737

38-
void FinalizeSkData(void* isolate_callback_data,
39-
Dart_WeakPersistentHandle handle,
40-
void* peer) {
38+
void FinalizeSkData(void* isolate_callback_data, void* peer) {
4139
SkData* buffer = reinterpret_cast<SkData*>(peer);
4240
buffer->unref();
4341
}

runtime/dart_isolate.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,11 @@ void DartIsolate::AddIsolateShutdownCallback(const fml::closure& closure) {
981981
}
982982

983983
void DartIsolate::OnShutdownCallback() {
984+
tonic::DartState* state = tonic::DartState::Current();
985+
if (state != nullptr) {
986+
state->SetIsShuttingDown();
987+
}
988+
984989
{
985990
tonic::DartApiScope api_scope;
986991
Dart_Handle sticky_error = Dart_GetStickyError();

shell/platform/embedder/embedder.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,8 +1922,7 @@ FlutterEngineResult FlutterEnginePostDartObject(
19221922
dart_object.value.as_external_typed_data.data = buffer;
19231923
dart_object.value.as_external_typed_data.peer = peer;
19241924
dart_object.value.as_external_typed_data.callback =
1925-
+[](void* unused_isolate_callback_data,
1926-
Dart_WeakPersistentHandle unused_handle, void* peer) {
1925+
+[](void* unused_isolate_callback_data, void* peer) {
19271926
auto typed_peer = reinterpret_cast<ExternalTypedDataPeer*>(peer);
19281927
typed_peer->trampoline(typed_peer->user_data);
19291928
delete typed_peer;

shell/platform/fuchsia/dart_runner/dart_runner.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ void IsolateShutdownCallback(void* isolate_group_data, void* isolate_data) {
8686
tonic::DartMicrotaskQueue::GetForCurrentThread()->Destroy();
8787
async_loop_quit(loop);
8888
}
89+
90+
auto state =
91+
static_cast<std::shared_ptr<tonic::DartState>*>(isolate_group_data);
92+
state->get()->SetIsShuttingDown();
8993
}
9094

9195
void IsolateGroupCleanupCallback(void* isolate_group_data) {

testing/run_tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def RunCCTests(build_dir, filter):
132132

133133
RunEngineExecutable(build_dir, 'runtime_unittests', filter, shuffle_flags)
134134

135+
RunEngineExecutable(build_dir, 'tonic_unittests', filter, shuffle_flags)
136+
135137
if not IsWindows():
136138
# https://github.com/flutter/flutter/issues/36295
137139
RunEngineExecutable(build_dir, 'shell_unittests', filter, shuffle_flags)

third_party/tonic/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ source_set("tonic") {
3535
"dart_persistent_value.h",
3636
"dart_state.cc",
3737
"dart_state.h",
38+
"dart_weak_persistent_value.cc",
39+
"dart_weak_persistent_value.h",
3840
"dart_wrappable.cc",
3941
"dart_wrappable.h",
4042
"dart_wrapper_info.h",

third_party/tonic/dart_state.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ DartState::DartState(int dirfd,
2727
message_handler_(new DartMessageHandler()),
2828
file_loader_(new FileLoader(dirfd)),
2929
message_epilogue_(message_epilogue),
30-
has_set_return_code_(false) {}
30+
has_set_return_code_(false),
31+
is_shutting_down_(false) {}
3132

3233
DartState::~DartState() {}
3334

0 commit comments

Comments
 (0)