diff --git a/sky/shell/platform/mac/platform_mac.mm b/sky/shell/platform/mac/platform_mac.mm index 8143e5134d8..ba14a744d22 100644 --- a/sky/shell/platform/mac/platform_mac.mm +++ b/sky/shell/platform/mac/platform_mac.mm @@ -15,6 +15,8 @@ #include "mojo/edk/embedder/embedder.h" #include "mojo/edk/embedder/simple_platform_support.h" #include "sky/shell/shell.h" +#include "sky/shell/switches.h" +#include "sky/shell/tracing_controller.h" #include "sky/shell/ui_delegate.h" #include "ui/gl/gl_surface.h" @@ -53,6 +55,16 @@ int PlatformMacMain(int argc, InitializeLogging(); + base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(sky::shell::switches::kTraceStartup)) { + // Usually, all tracing within flutter is managed via the tracing controller + // The tracing controller is accessed via the shell instance. This means + // that tracing can only be enabled once that instance is created. Traces + // early in startup are lost. This enables tracing only in base manually + // till the tracing controller takes over. + sky::shell::TracingController::StartBaseTracing(); + } + scoped_ptr message_loop(new base::MessageLoopForUI()); #if TARGET_OS_IPHONE diff --git a/sky/shell/tracing_controller.h b/sky/shell/tracing_controller.h index a6c5dbd7344..3a587f6ff1e 100644 --- a/sky/shell/tracing_controller.h +++ b/sky/shell/tracing_controller.h @@ -28,6 +28,12 @@ class TracingController { void StopTracing(const base::FilePath& path, bool terminateLoopWhenDone = false); + // Enables tracing in base. Only use this if an instance of a tracing + // controller cannot be obtained (can happen early in the lifecycle of the + // process). In most cases, the |StartTracing| method on an instance of the + // tracing controller should be used. + static void StartBaseTracing(); + base::FilePath PictureTracingPathForCurrentTime() const; base::FilePath PictureTracingPathForCurrentTime(base::FilePath dir) const; @@ -57,7 +63,6 @@ class TracingController { bool tracing_active_; void StartDartTracing(); - void StartBaseTracing(); void StopDartTracing(); void StopBaseTracing(); void FinalizeTraceFile();