Skip to content

Performance audit embedding Flutter view initialization time #32945

Closed

Description

@xster

It may be unavoidable for users to need to embed a flutter view in their application's home screen.

Trace the various cold initialization steps, see if any low hanging fruits can be targeted.

If not, document how users can sync up their native view appearance with the first frame listener.

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    a: existing-appsIntegration with existing apps via the add-to-app flow
    on May 17, 2019
  2. gaaclarke commented on Jul 19, 2019

    @gaaclarke
    Member

    We've done a few things that make this better:

    1. ShaderWarmUp works in add to app now: Made Picture::toImage happen on the IO thread with no need for an onscreen surface. flutter-team-archive/engine#9813
    2. Added synchronization with main thread: Synchronize main thread and gpu thread for first render frame flutter-team-archive/engine#9506
    3. Fixed the first frame callback for add to app case: ios: Fixed the callback for the first frame so that it isn't predicated on having a splash screen. flutter-team-archive/engine#9952
    4. Made ShaderWarmUp faster: Sped up shader warmup by only drawing on a 100x100 surface #36482

    Here is a recent sample from app startup time (tested against PR 36482)
    Screen Shot 2019-07-19 at 2 32 00 PM
    little.json.gz
    (Sample taken in iPhone SE)

    ~80ms is spent in FontCollection::FindFontFamilyInManagers. That seems to be the place currently with a lot of opportunity outside of Skia. We should use a more complete profiler to introspect into Skia as well.

  3. xster commented on Jul 19, 2019

    @xster
    MemberAuthor

    This is all in profile mode right? 300ms of pure dart code for one frame does seem a bit intense. Though given a prewarm'ed engine (on which we called runWithEntrypoint ahead of time), this cost is hidden right?

  4. gaaclarke commented on Jul 19, 2019

    @gaaclarke
    Member

    An instruments profile confirms there is a lot of work being done with fonts:
    Screen Shot 2019-07-19 at 3 08 34 PM
    flutterstartup.trace.zip

  5. gaaclarke commented on Jul 19, 2019

    @gaaclarke
    Member

    This is all in profile mode right? 300ms of pure dart code for one frame does seem a bit intense. Though given a prewarm'ed engine (on which we called runWithEntrypoint ahead of time), this cost is hidden right?

    Yep, both samples are in profile mode.

  6. xster commented on Jul 19, 2019

    @xster
    MemberAuthor

    Also cc @GaryQian @jason-simmons for any potential optimizations on the font manager (potentially doing things before the first Dart frame)

  7. modified the milestones: December 2019 (Add-to-App), , on Jan 7, 2020
  8. added
    P2Important issues not at the top of the work list
    on May 29, 2020
  9. removed this from the milestone on Aug 17, 2020
  10. jonahwilliams commented on Aug 30, 2024

    @jonahwilliams
    Contributor

    Seems like we did do the audit. Hopefully any follow up tasks were filled and or completed

  11. github-actions commented on Sep 13, 2024

    @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.

  12. locked as resolved and limited conversation to collaborators on Sep 13, 2024
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

    P2Important issues not at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowc: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions