Skip to content

Add flutter frame identifier to timeline events on UI and Raster threads #80735

Closed

Description

@kenzieschmoll

In DevTools, we need a way to connect Flutter.Frame events (sent here) to their corresponding timeline events on the UI and Raster threads. This is a requirement in order to make the DevTools timeline show live frame data.

We cannot connect a Flutter.Frame event to its corresponding timeline events by timestamp because the two data sources use different clocks. From @iskakaushik:

Based on some initial observations, there doesn't seem to be an easy way to convert between Dart Timeline and Flutter Clocks. For example, on iOS, Dart timeline seems to use "mach_absolute_time" which doesn't increment when the system is asleep, whereas in Flutter we use "std::chrono::steady_clock()" which is independent of the system uptime.

If we could add metadata to the root UI thread and root Raster thread event that would allow us to associate those two timeline events with a Flutter.Frame event, that would work. Perhaps adding an arg "frameNumber" that matches the "number" field from Flutter.Frame events.

Activity

  1. jonahwilliams commented on Apr 19, 2021

    @jonahwilliams
    Contributor

    @kenzieschmoll is there any reason not to go with the frame-janks-are-errors design of have the framework plumb through the frame identifier? If not, I can wire that up fairly quickly....

  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    P3Issues that are less important to the Flutter project
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    c: new featureNothing broken; request for a new capability
    on Apr 19, 2021
  3. kenzieschmoll commented on Apr 19, 2021

    @kenzieschmoll
    MemberAuthor

    the frame-janks-are-errors design of have the framework plumb through the frame identifier

    would this result in both the UI root event and the Raster root event having the identifier in their trace events?

  4. jonahwilliams commented on Apr 19, 2021

    @jonahwilliams
    Contributor

    Yes, the information should be available in the engine when we write the traces. I didn't wire that up in the prototype but can't imagine it would be that hard (famous last words)

  5. kenzieschmoll commented on Apr 19, 2021

    @kenzieschmoll
    MemberAuthor

    Then that sounds like exactly what we need.

  6. iskakaushik commented on Apr 21, 2021

    @iskakaushik
    Contributor

    Capturing the offline discussion with @jonahwilliams:

    I like the idea of having a frame identifier that is associated with trace events. Given that engine triggers the frame build and raster process, it would be best if engine does the creation and managing lifecycle of the said frame identifier.

    Next steps are for Jonah and I to iterate on flutter-team-archive/engine#25662.

  7. jonahwilliams commented on Apr 30, 2021

    @jonahwilliams
    Contributor

    Another use for this would be flutter/devtools#2943

  8. kenzieschmoll commented on Apr 30, 2021

    @kenzieschmoll
    MemberAuthor

    Another use for this would be flutter/devtools#2943

    To meet this use case, the starting frame number would need to be consistent (0-based or 1-based) so we can identify the first frame for an app run.

  9. iskakaushik commented on May 12, 2021

    @iskakaushik
    Contributor

    flutter-team-archive/engine#25892 and flutter-team-archive/engine#26021 partially address the issue. Per my conversations with @jonahwilliams and @kenzieschmoll , the next AIs are:

    1. @iskakaushik to add the frame_number as a trace event argument in animator and rasterizer events.
    2. @jonahwilliams to propagate the frame_number field via the service protocol FrameTimings APIs.
    3. @kenzieschmoll will then change dev-tools to account for these changes.

    Thanks and let me know if I'm missing something here.

  10. kenzieschmoll commented on May 24, 2021

    @kenzieschmoll
    MemberAuthor

    Interestingly, the frame numbers don't seem to be incrementing by 1. In this example they are increasing by 3 - is that expected? @iskakaushik @jonahwilliams
    Screen Shot 2021-05-24 at 9 32 47 AM

  11. jonahwilliams commented on May 24, 2021

    @jonahwilliams
    Contributor

    That is surprising to me at least :)

  12. iskakaushik commented on Jun 1, 2021

    @iskakaushik
    Contributor

    I saw it alternating each time, 1, 3, 5...

    This PR should fix it: flutter-team-archive/engine#26513. At least locally after this change I'm seeing every number appear.

  13. zanderso commented on Jul 8, 2021

    @zanderso
    Member

    What is left to do for this?

  14. kenzieschmoll commented on Jul 12, 2021

    @kenzieschmoll
    MemberAuthor

    I think this is complete.

  15. github-actions commented on Jul 30, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: performanceRelates to speed or footprint issues (see "perf:" labels)frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions