未验证 提交 8a465596 编写于 作者: N nathanrogersgoogle 提交者: GitHub

Route FlutterEventTracer events to Fuchsia tracing for Fuchsia (#8499)

When running on Fuchsia, "fml/trace_event.h" sends trace events towards
Fuchsia's tracing system, rather than its own |fml::tracing::*| one.  Do
the same thing for |FlutterEventTracer|, in order to unlock category
"skia" trace events when running on Fuchsia.

The reason this was not working before is because |FlutterEventTracer|
was directly using |fml::tracing::*| functions, rather than the
TRACE_EVENT_* macros.

In the future, we can look into having the skia event tracer enabled by
default on Fuchsia, controlling the presence of Skia events by
enabling/disabling the "skia" category, once we measure the performance
cost of doing so.
上级 7ce64be6
......@@ -5,11 +5,10 @@
#include "flutter/shell/common/skia_event_tracer_impl.h"
#define TRACE_EVENT_HIDE_MACROS
#include "flutter/fml/trace_event.h"
#include <vector>
#include "flutter/fml/logging.h"
#include "flutter/fml/trace_event.h"
#include "third_party/dart/runtime/include/dart_tools_api.h"
#include "third_party/skia/include/utils/SkEventTracer.h"
#include "third_party/skia/include/utils/SkTraceEventPhase.h"
......@@ -33,6 +32,30 @@ class FlutterEventTracer : public SkEventTracer {
const uint8_t* p_arg_types,
const uint64_t* p_arg_values,
uint8_t flags) override {
#if defined(OS_FUCHSIA)
// In a manner analogous to "fml/trace_event.h", use Fuchsia's system
// tracing macros when running on Fuchsia.
switch (phase) {
case TRACE_EVENT_PHASE_BEGIN:
case TRACE_EVENT_PHASE_COMPLETE:
TRACE_DURATION_BEGIN(kSkiaTag, name);
break;
case TRACE_EVENT_PHASE_END:
TRACE_DURATION_END(kSkiaTag, name);
break;
case TRACE_EVENT_PHASE_INSTANT:
TRACE_INSTANT(kSkiaTag, name, TRACE_SCOPE_THREAD);
break;
case TRACE_EVENT_PHASE_ASYNC_BEGIN:
TRACE_ASYNC_BEGIN(kSkiaTag, name, id);
break;
case TRACE_EVENT_PHASE_ASYNC_END:
TRACE_ASYNC_END(kSkiaTag, name, id);
break;
default:
break;
}
#else // defined(OS_FUCHSIA)
switch (phase) {
case TRACE_EVENT_PHASE_BEGIN:
case TRACE_EVENT_PHASE_COMPLETE:
......@@ -53,6 +76,7 @@ class FlutterEventTracer : public SkEventTracer {
default:
break;
}
#endif // defined(OS_FUCHSIA)
return 0;
}
......@@ -61,7 +85,11 @@ class FlutterEventTracer : public SkEventTracer {
SkEventTracer::Handle handle) override {
// This is only ever called from a scoped trace event so we will just end
// the section.
#if defined(OS_FUCHSIA)
TRACE_DURATION_END(kSkiaTag, name);
#else
fml::tracing::TraceEventEnd(name);
#endif
}
const uint8_t* getCategoryGroupEnabled(const char* name) override {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册