Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 838a89f

Browse files
committed
Make Shell::NotifyLowMemoryWarning trace
1 parent 291dab6 commit 838a89f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

shell/common/shell.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,18 +430,23 @@ Shell::~Shell() {
430430
platform_latch.Wait();
431431
}
432432

433-
void Shell::NotifyLowMemoryWarning() const {
433+
void Shell::NotifyLowMemoryWarning() {
434+
TRACE_EVENT_ASYNC_BEGIN0("flutter", "Shell::NotifyLowMemoryWarning",
435+
notify_low_memory_trace_id_);
434436
// This does not require a current isolate but does require a running VM.
435437
// Since a valid shell will not be returned to the embedder without a valid
436438
// DartVMRef, we can be certain that this is a safe spot to assume a VM is
437439
// running.
438440
::Dart_NotifyLowMemory();
439441

440442
task_runners_.GetRasterTaskRunner()->PostTask(
441-
[rasterizer = rasterizer_->GetWeakPtr()]() {
443+
[rasterizer = rasterizer_->GetWeakPtr(),
444+
trace_id = notify_low_memory_trace_id_++]() {
442445
if (rasterizer) {
443446
rasterizer->NotifyLowMemoryWarning();
444447
}
448+
TRACE_EVENT_ASYNC_END0("flutter", "Shell::NotifyLowMemoryWarning",
449+
trace_id);
445450
});
446451
// The IO Manager uses resource cache limits of 0, so it is not necessary
447452
// to purge them.

shell/common/shell.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class Shell final : public PlatformView::Delegate,
284284
/// @brief Used by embedders to notify that there is a low memory
285285
/// warning. The shell will attempt to purge caches. Current, only
286286
/// the rasterizer cache is purged.
287-
void NotifyLowMemoryWarning() const;
287+
void NotifyLowMemoryWarning();
288288

289289
//----------------------------------------------------------------------------
290290
/// @brief Used by embedders to check if all shell subcomponents are
@@ -397,6 +397,7 @@ class Shell final : public PlatformView::Delegate,
397397
std::atomic<bool> waiting_for_first_frame_ = true;
398398
std::mutex waiting_for_first_frame_mutex_;
399399
std::condition_variable waiting_for_first_frame_condition_;
400+
size_t notify_low_memory_trace_id_ = 0;
400401

401402
// Written in the UI thread and read from the raster thread. Hence make it
402403
// atomic.

0 commit comments

Comments
 (0)