Constellation can now optionally report memory usage when the page is loaded. (#37151)

The constellation can now tell the memory reporter to report the memory
to a trace file when a page is loaded.
Additionally, we amend the memory reporter to allow a simple message
where it will report the memory to a tracing provider (at the moment
only OHOS/hitrace is supported but easy extension is possible).

I am not sure if this is the right approach or if the embedder should
decide to have the memory reporting done.

Testing: This does not change functionality of any of the rendering.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
Narfinger 2025-05-30 19:15:06 +02:00 committed by GitHub
parent 5580704438
commit 13a980ff22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 1 deletions

View file

@ -152,6 +152,24 @@ impl WebViewDelegate for RunningAppState {
self.callbacks
.host_callbacks
.notify_load_status_changed(load_status);
#[cfg(feature = "tracing")]
if load_status == LoadStatus::Complete {
#[cfg(feature = "tracing-hitrace")]
let (snd, recv) = ipc_channel::ipc::channel().expect("Could not create channel");
self.servo.create_memory_report(snd);
std::thread::spawn(move || {
let result = recv.recv().expect("Could not get memory report");
let reports = result
.results
.first()
.expect("We should have some memory report");
for report in &reports.reports {
let path = String::from("servo_memory_profiling:") + &report.path.join("/");
hitrace::trace_metric_str(&path, report.size as i64);
}
});
}
}
fn notify_closed(&self, webview: WebView) {