Skip to content

systrace don't support async timeline events #39726

@yuanhuihui

Description

@yuanhuihui

For example, async events in Flutter engine:

TRACE_EVENT_ASYNC_BEGIN0("flutter", "Frame Request Pending", frame_number);
...
TRACE_EVENT_ASYNC_END0("flutter", "Frame Request Pending", frame_number_++);
  1. Show in Timeline:

1-1-timeline-origin

  1. set FLAG_systrace_timeline = true, then change timeline recorder to TimelineEventSystraceRecorder on Android

Don't have any async events in systrace:

1-2-timeline-origin-systrace

  1. With this PR, we can see async events, such as Frame Request Pending:

1-3-timeline-opt1-systrace

// in Android Platform,  path: android/system/core/libcutils/trace-dev.c
void atrace_async_begin_body(const char* name, int32_t cookie)
{
    char buf[ATRACE_MESSAGE_LENGTH];
    size_t len;

    len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "S|%d|%s|%" PRId32,
            getpid(), name, cookie);
    write(atrace_marker_fd, buf, len);
}

void atrace_async_end_body(const char* name, int32_t cookie)
{
    char buf[ATRACE_MESSAGE_LENGTH];
    size_t len;

    len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "F|%d|%s|%" PRId32,
            getpid(), name, cookie);
    write(atrace_marker_fd, buf, len);
}

support TimelineEvent kAsyncBegin and kAsyncEnd with S/F.

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.pkg-vm-service

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions