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

Commit 1628bbd

Browse files
committed
WeakPersistentHandle migration
1 parent 78a0181 commit 1628bbd

21 files changed

+487
-41
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: 1 addition & 1 deletion
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': 'd2577410a5016eadc111919355e19d42dd45d816',
37+
'dart_revision': '52783837369de45d3372cb6c6b7cdd63e71cd829',
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

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,8 @@ FILE: ../../../flutter/third_party/tonic/dart_persistent_value.cc
14631463
FILE: ../../../flutter/third_party/tonic/dart_persistent_value.h
14641464
FILE: ../../../flutter/third_party/tonic/dart_state.cc
14651465
FILE: ../../../flutter/third_party/tonic/dart_state.h
1466+
FILE: ../../../flutter/third_party/tonic/dart_weak_persistent_value.cc
1467+
FILE: ../../../flutter/third_party/tonic/dart_weak_persistent_value.h
14661468
FILE: ../../../flutter/third_party/tonic/dart_wrappable.cc
14671469
FILE: ../../../flutter/third_party/tonic/dart_wrappable.h
14681470
FILE: ../../../flutter/third_party/tonic/dart_wrapper_info.h

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",

0 commit comments

Comments
 (0)