Skip to content

Register additional Service Extensions to Flutter Tool for DevTools Profiling #41225

Description

@terrylucas

Use case

Flutter DevTools today reports the resident set size (RSS) of a Flutter application. The RSS is an opaque value (just the total size) not very informative. We would like to display the RSS but we'd like to display additional information (from dumpsys meminfo) e.g., Java Heap, Native Heap, Code, Stack, Graphics, Private Other, and System that comprise the RSS.

To do this we would need to send adb shell commands e.g.,

adb shell dumpsys meminfo <package_name>

Today we can't be connected to both the VMService and adb on the same Flutter app profile run.

If the last connection is DevTools then 'adb shell' causes DevTools to exit.

Proposal

After talking to @jonahwilliams he believes this could be implemented by having the flutter tool register additional service extensions which ultimately shelled out to adb or other system tools. That would make it usable via anything that has a vmservice connection I think?

The caveat here is that the way our vmservice connections are currently designed, by the time we get to the vmservice connection we've forgotten what device we're running on. I think that would be fixable via some plumbing though. I would also need to find the package but I could use:

dumpsys window windows | grep -E 'mFocusedApp'

This feature would allow DevTools to keep our VM Service connection (talking to the VM) as well as issuing adb shell commands dumpsys meminfo and parsing the stdout (as well as other interesting stuff like batterystats, netstats, etc.)

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Sep 24, 2019
  2. added this to the December 2019 milestone on Sep 24, 2019
  3. jonahwilliams commented on Nov 25, 2019

    @jonahwilliams
    Contributor

    dumpsys returns a table like:

    ** MEMINFO in pid 16141 [io.flutter.demo.gallery] **
                       Pss  Private  Private  SwapPss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------
      Native Heap     8648     8620        0       16    20480    12403     8076
      Dalvik Heap      547      424       40       18     2628     1092     1536
     Dalvik Other      464      464        0        0                           
            Stack      496      496        0        0                           
           Ashmem        2        0        0        0                           
          Gfx dev      212      204        0        0                           
        Other dev       48        0       48        0                           
         .so mmap    10770      708     9372       25                           
        .apk mmap      240        0        0        0                           
        .ttf mmap       35        0       32        0                           
        .dex mmap     2205        4     1172        0                           
        .oat mmap       64        0        0        0                           
        .art mmap     4228     3848       24        2                           
       Other mmap    20713        4    20704        0                           
        GL mtrack     2380     2380        0        0                           
          Unknown    43971    43968        0        1                           
            TOTAL    95085    61120    31392       62    23108    13495     9612
     
     App Summary
                           Pss(KB)
                            ------
               Java Heap:     4296
             Native Heap:     8620
                    Code:    11288
                   Stack:      496
                Graphics:     2584
           Private Other:    65228
                  System:     2573
     
                   TOTAL:    95085       TOTAL SWAP PSS:       62
     
     Objects
                   Views:        9         ViewRootImpl:        1
             AppContexts:        3           Activities:        1
                  Assets:        4        AssetManagers:        3
           Local Binders:       10        Proxy Binders:       18
           Parcel memory:        6         Parcel count:       24
        Death Recipients:        0      OpenSSL Sockets:        0
                WebViews:        0
     
     SQL
             MEMORY_USED:        0
      PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0
    

    Which information here is the most important? I'm not quite sure how stable this structure is, but I should be able to parse most of it if needed

  4. github-actions commented on Aug 25, 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.

  5. locked as resolved and limited conversation to collaborators on Aug 25, 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

    c: proposalA detailed proposal for a change to Fluttercustomer: googleVarious Google teamstoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions