Skip to content

Commit 0ea826d

Browse files
committed
[dart/flutter_runner] Copy package.resolved_url for TRACE_DURATION
Ensure that the string data backing package.resolved_url is not modified or moved by making a copy to pass as the argument value for TRACE_DURATION. PT-169 #comment Change-Id: I1ef6ab9b1ecf350e82134d1d616a841611ac19c6 Ported from Topaz tree.
1 parent c13374b commit 0ea826d

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

shell/platform/fuchsia/dart/dart_runner.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,14 @@ void DartRunner::StartComponent(
189189
fuchsia::sys::Package package,
190190
fuchsia::sys::StartupInfo startup_info,
191191
::fidl::InterfaceRequest<fuchsia::sys::ComponentController> controller) {
192-
TRACE_EVENT1("dart", "StartComponent", "url", package.resolved_url.c_str());
192+
// TRACE_DURATION currently requires that the string data does not change
193+
// in the traced scope. Since |package| gets moved in the construction of
194+
// |thread| below, we cannot ensure that |package.resolved_url| does not
195+
// move or change, so we make a copy to pass to TRACE_DURATION.
196+
// TODO(PT-169): Remove this copy when TRACE_DURATION reads string arguments
197+
// eagerly.
198+
std::string url_copy = package.resolved_url;
199+
TRACE_EVENT1("dart", "StartComponent", "url", url_copy.c_str());
193200
std::thread thread(RunApplication, this, std::move(package),
194201
std::move(startup_info), context_->svc(),
195202
std::move(controller));

shell/platform/fuchsia/flutter/runner.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ void Runner::StartComponent(
137137
fuchsia::sys::Package package,
138138
fuchsia::sys::StartupInfo startup_info,
139139
fidl::InterfaceRequest<fuchsia::sys::ComponentController> controller) {
140-
TRACE_EVENT0("flutter", "StartComponent");
140+
// TRACE_DURATION currently requires that the string data does not change
141+
// in the traced scope. Since |package| gets moved in the Application::Create
142+
// call below, we cannot ensure that |package.resolved_url| does not move or
143+
// change, so we make a copy to pass to TRACE_DURATION.
144+
// TODO(PT-169): Remove this copy when TRACE_DURATION reads string arguments
145+
// eagerly.
146+
std::string url_copy = package.resolved_url;
147+
TRACE_EVENT1("flutter", "StartComponent", "url", url_copy.c_str());
141148
// Notes on application termination: Application typically terminate on the
142149
// thread on which they were created. This usually means the thread was
143150
// specifically created to host the application. But we want to ensure that

0 commit comments

Comments
 (0)