Skip to content

Commit

Permalink
Do not modify the set of active streams within the embedder tracing c…
Browse files Browse the repository at this point in the history
…allbacks (flutter#2600)

Dart invokes Start/StopTracing callbacks within the _setVMTimelineFlags service
method whenever the embedder timeline stream toggles on or off.  Flutter's
implementation of these callbacks was modifying the set of enabled streams,
which could override the intended behavior of _setVMTimelineFlags.

Start/StopTracing will now only control Flutter's embedder-specific log.

Also needed to change the Flutter engine's --trace-startup flag to set the
corresponding timeline stream flag on the Dart VM.
  • Loading branch information
jason-simmons committed Apr 19, 2016
1 parent 284929b commit 48de25e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
7 changes: 7 additions & 0 deletions sky/engine/core/script/dart_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ static const char* kDartStartPausedArgs[]{
"--pause_isolates_on_start",
};

static const char* kDartTraceStartupArgs[]{
"--timeline_streams=Compiler,Dart,Embedder,GC",
};

const char kFileUriPrefix[] = "file://";

const char kDartFlags[] = "dart-flags";
Expand Down Expand Up @@ -410,6 +414,9 @@ void InitDartVM() {
if (SkySettings::Get().start_paused)
args.append(kDartStartPausedArgs, arraysize(kDartStartPausedArgs));

if (SkySettings::Get().trace_startup)
args.append(kDartTraceStartupArgs, arraysize(kDartTraceStartupArgs));

Vector<std::string> dart_flags;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDartFlags)) {
// Instruct the VM to ignore unrecognized flags.
Expand Down
1 change: 1 addition & 0 deletions sky/engine/public/platform/sky_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct SkySettings {
uint32_t observatory_port = 0;
bool start_paused = false;
bool enable_dart_checked_mode = false;
bool trace_startup = false;

static const SkySettings& Get();
static void Set(const SkySettings& settings);
Expand Down
4 changes: 1 addition & 3 deletions sky/shell/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,10 @@ void Shell::InitStandalone(std::string icu_data_path) {
settings.start_paused = command_line.HasSwitch(switches::kStartPaused);
settings.enable_dart_checked_mode =
command_line.HasSwitch(switches::kEnableCheckedMode);
settings.trace_startup = command_line.HasSwitch(switches::kTraceStartup);
blink::SkySettings::Set(settings);

Init();

if (command_line.HasSwitch(switches::kTraceStartup))
Shared().tracing_controller().StartTracing();
}

void Shell::Init() {
Expand Down
10 changes: 0 additions & 10 deletions sky/shell/tracing_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,11 @@ void TracingController::StartTracing() {

tracing_active_ = true;

StartDartTracing();
StartBaseTracing();

AddTraceMetadata();
}

void TracingController::StartDartTracing() {
Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL);
}

void TracingController::StartBaseTracing() {
namespace TE = base::trace_event;
auto config = TE::TraceConfig("*", TE::RECORD_CONTINUOUSLY);
Expand All @@ -199,7 +194,6 @@ void TracingController::StopTracing() {
tracing_active_ = false;

StopBaseTracing();
StopDartTracing();
}

void TracingController::StopBaseTracing() {
Expand All @@ -209,10 +203,6 @@ void TracingController::StopBaseTracing() {
log->SetEventCallbackDisabled();
}

void TracingController::StopDartTracing() {
Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_DISABLE);
}

base::FilePath TracingController::TracePathWithExtension(
base::FilePath dir,
std::string extension) const {
Expand Down
3 changes: 0 additions & 3 deletions sky/shell/tracing_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class TracingController {

void StopBaseTracing();

void StartDartTracing();
void StopDartTracing();

base::FilePath TracePathWithExtension(base::FilePath dir,
std::string extension) const;

Expand Down

0 comments on commit 48de25e

Please sign in to comment.