Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ADB (Android Java memory info), multiple charts, Display … #1553

Merged
merged 23 commits into from
Jan 27, 2020

Conversation

terrylucas
Copy link
Contributor

@terrylucas terrylucas commented Jan 16, 2020

Features added in this PR:

  • Added collecting ADB (Android Java memory info)
  • Added multiple charts (Dart VM and ADB memory information)
  • Added Display interval e.g., 1 minute, 5 minutes, 10 minutes, etc.
  • Updated exported JSON format both Dart VM and ADB memory information.
  • Beginning of timeline slider to select beginning interval 5 minutes ago, 10 minutes ago, etc. Not fully implemented but correctly displays the historical starting points based on current display interval with temporal change as data is collected.
  • Added robust marker (legend of a datapoint values for a particular timestamp).
  • Handle iOS devices graying the ADB Memory chart button.
  • Graceful resize of button/drop-downs for narrow windows (e.g., MediaQuery is narrow).
  • Correctly, handle canceling timers (other cleanup) when widgets disposed.
  • Cleaned up buttons to use only Material Icons.
  • Fixed markers computations based on text height fixes layout in both Flutter Desktop Mac vs Linux.
  • Added a Clear button on the left-side to dispose of any collected live data.
  • A number of charting bugs have also been fixed e.g., NaN and INF values (uninitialized data attempting to be plotted), scale factors for both X and Y axis.

Memory View now has the ability to display collected ADB memory statistics (Java Heap).

image

On startup the Memory Profile View is displayed with a chart of the collect Dart VM memory statistics:

image

Clicking on the Android Memory button

image

Will display a second chart of Android's memory e.g.,

image

image

Other
Other private memory usage corresponds to the Private Other field output in the App Summary.Android Studio: Memory used by the app that the system isn't sure how to categorize.

System
Shared and system memory usage in kB. This corresponds to the System field output in the App Summary.

Note: The Other trace (plot in the chart) is the combined values of Other and System.

Code
The memory usage for static code and resources corresponds to the Code field in the App Summary..Android Studio: Memory that your app uses for code and resources, such as dex byte code, optimized or compiled dex code, .so libraries, and fonts.

Native Heap
The private Native Heap usage corresponds to the Native Heap field in the App Summary.Android Studio: Memory from objects allocated from C or C++ code. Even if you're not using C++ in your app, you might see some native memory used here because the Android framework uses native memory to handle various tasks on your behalf, such as when handling image assets and other graphics—even though the code you've written is in Java or Kotlin.

Java Heap
The private Java Heap usage corresponds to the Java Heap field in the App Summary. Android Studio: Memory from objects allocated from Java or Kotlin code.

Stack
The stack usage corresponds to the Stack field in the App Summary.Android Studio: Memory used by both native and Java stacks in your app. This usually relates to how many threads your app is running.

Graphics
The graphics usage corresponds to the Graphics field in the App Summary.Android Studio: Memory used for graphics buffer queues to display pixels to the screen, including GL surfaces, GL textures, and so on. (Note that this is memory shared with the CPU, not dedicated GPU memory.)

Display Interval Feature
The display interval is a drop-down setting the viewport of the chart to a period of time e.g., 1 minute, 5 minutes, 10 minutes or all minutes.

image

Graceful resize of button/drop-downs for compact displays normally for wide DevTools app the toolbar is:

image

As the application's width narrows portions of the memory actions (buttons and drop-downs) will narrow (icon only) the first is the left-side buttons e.g.,

image

Then the right-side buttons e.g.,

image

And, finally the drop-downs narrow e.g.,

image

The JSON format of collected memory statistics is:

{
  "samples" : {
    "version" : 1,
    // data is an array of collected memory statistics with a different timestamp.
    "data" : [
      {
        "timestamp" : 1579794829976,
        "rss" : 236605440,
        "capacity" : 71211528,
        "used" : 66910904,
        "external" : 223752,
        "gc" : false,
        "adb_memoryInfo" : {
          "Realtime" : 1154887,
          "Java Heap" : 7680,
          "Native Heap" : 12088,
          "Code" : 19328,
          "Stack" : 64,
          "Graphics" : 0,
          "Private Other" : 114384,
          "System" : 6323,
          "Total" : 159867
        }
      },
      {
       "timestamp" : 1579794830276,
        "rss" : 236380160,
...
        "adb_memoryInfo" : {
          "Realtime" : 1155191,
...
        }
      },
    ],
  }
}

Copy link
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with first round of comments. Also, please add tests.


_timelineSlider = Slider.adaptive(
label: timelineSliderLabel(controller.sliderValue),
activeColor: Colors.indigoAccent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use a color from Theme.of(context) instead? or just use the default (which I assume would be the same color as the switch on the timeline page)?

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm from me with some nits.
I'm fine with adding tests as a followup cl as this cl is already large. lets figure out how to test this code more productively than we have in the past perhaps by writing flutter widget tests that talk to a real vm service.

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants