diff --git a/BUILD.gn b/BUILD.gn index 2a2d3b7925..825c63da86 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -554,6 +554,7 @@ source_set("electron_lib") { "//services/device/public/cpp/hid", "//services/device/public/mojom", "//services/proxy_resolver:lib", + "//services/tracing/public/cpp", "//services/video_capture/public/mojom:constants", "//services/viz/privileged/mojom/compositing", "//services/viz/public/mojom", @@ -572,6 +573,7 @@ source_set("electron_lib") { "//third_party/inspector_protocol:crdtp", "//third_party/leveldatabase", "//third_party/libyuv", + "//third_party/perfetto/protos/perfetto/config:cpp", "//third_party/webrtc_overrides:webrtc_component", "//third_party/widevine/cdm:headers", "//third_party/zlib/google:zip", diff --git a/build/lsan_suppressions.txt b/build/lsan_suppressions.txt index 158225d14f..f3220d118d 100644 --- a/build/lsan_suppressions.txt +++ b/build/lsan_suppressions.txt @@ -12,3 +12,12 @@ leak:third_party/fontconfig # GLib/GTK process-lifetime state (type system, quarks, theme and settings # caches) that is never freed by design. leak:libglib-2.0.so + +# base::PoissonAllocationSampler deliberately leaks its previous +# sampled-address hash set when the set grows (see +# PoissonAllocationSampler::BalanceAddressesHashSet), since lock-free +# readers may still hold pointers to the old map. The heap-profiling +# contentTracing specs are the first tests to actually engage the +# sampler, so the initial 64-bucket set gets swapped out and reported. +# One-time and bounded (~1KB per growth step). +leak:base/sampling_heap_profiler/ diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md index fad5c1227e..33540c53d8 100644 --- a/docs/api/content-tracing.md +++ b/docs/api/content-tracing.md @@ -4,8 +4,9 @@ Process: [Main](../glossary.md#main-process) -This module does not include a web interface. To view recorded traces, use -[trace viewer][], available at `chrome://tracing` in Chrome. +This module does not include a web interface. Traces are recorded in the +[Perfetto protobuf format][perfetto trace format]; to view them, open them in +the [Perfetto UI][]. > [!NOTE] > You should not use this module until the `ready` event of the app @@ -59,6 +60,8 @@ changes: - pr-url: https://github.com/electron/electron/pull/16584 description: "This function now returns a callback`Promise`." breaking-changes-header: api-changed-callback-based-versions-of-promisified-apis + - pr-url: https://github.com/electron/electron/pull/53349 + description: "Added the `nativeHeapProfiling` option to enable native heap profiling." ``` --> @@ -72,7 +75,10 @@ Recording begins immediately locally and asynchronously on child processes as soon as they receive the EnableRecording request. If a recording is already running, the promise will be immediately resolved, as -only one trace operation can be in progress at a time. +only one trace operation can be in progress at a time. If `options.nativeHeapProfiling` +is set while a recording is already running, the promise is rejected instead, +since the already-running recording's options can't be changed to turn on heap +profiling. ### `contentTracing.stopRecording([resultFilePath])` @@ -84,6 +90,9 @@ changes: breaking-changes-header: api-changed-callback-based-versions-of-promisified-apis - pr-url: https://github.com/electron/electron/pull/18411 description: "The `resultFilePath` parameter is now optional." + - pr-url: https://github.com/electron/electron/pull/53349 + description: "Trace data is now written in the Perfetto protobuf format. The legacy JSON format is no longer supported." + breaking-changes-header: behavior-changed-contenttracing-recordings-use-the-perfetto-protobuf-format ``` --> @@ -103,6 +112,14 @@ Trace data will be written into `resultFilePath`. If `resultFilePath` is empty or not provided, trace data will be written to a temporary file, and the path will be returned in the promise. +Trace data is written in the [Perfetto protobuf format][perfetto trace format]. + +Heap profiling samples record instruction addresses and module build IDs rather +than function names. To symbolize them, use the symbols published for the +matching Electron release with Chromium's +[`symbolize_trace`](https://chromium.googlesource.com/chromium/src/+/main/tools/tracing/README.md) +tool. + ### `contentTracing.getTraceBufferUsage()`