-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
I'm not sure if this is just a documentation bug or something we want to actively make easier.
It's possible to run a Perfetto native heap trace on Android 9+. However, to get symbols in the trace, you need either an unstripped libflutter.so or be on Linux.
Here are the steps to get a symbolicated heapprofd trace today:
- Build the engine locally, using a gn invocation like the following:
flutter/tools/gn --android --android-cpu arm64 --no-strip
(with your preferred runtime mode/unopt settings). - Add the following to your Flutter application's
android/app/build.gradle
:
android {
// Other options...
packagingOptions {
doNotStrip '**/libflutter.so'
}
}
- Do a
flutter run --local-engine=android_debug_arm64
(replace the runtime mode to match the runtime from your locally built engine). - Clone https://github.com/google/perfetto
- Invoke the Perfetto
tools/trace_heap
script:tools/trace_heap -n com.example.myAppName
- Interact with your application.
Perfetto will tell you where it put the heap trace file at the end. Googlers can upload that to pprof, or anyone else can upload it to https://ui.perfetto.dev/#!/viewer
It is possible for Perfetto to apply the symbols, but currently that only works on Linux (a limitation in Perfetto itself).
We should either better document how to do this somewhere, or ideally make it easier for developers to do this. For example, if Perfetto can be made to add symbols for Mac/Windows, we could instruct developers to download the symbols for their particular engine build. It may also be more feasible to just provide unstripped artifacts for e.g. debug and profile mode, and provide instructions or flags to the tool to download them and use them for heap tracing.
/cc @terrylucas @jacob314
/cc @liyuqian
/cc @segfaulthunter fyi
/cc @zanderso @jonahwilliams for input on tooling options.