Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion shell/common/animator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ Animator::Animator(Delegate& delegate,
weak_factory_(this) {
}

Animator::~Animator() = default;
Animator::~Animator() {
// Remove all queued layer trees to ensure that Skia objects are unreffed.
layer_tree_pipeline_->Clear();
}

void Animator::Stop() {
paused_ = true;
Expand Down
12 changes: 12 additions & 0 deletions shell/common/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ class Pipeline : public fml::RefCountedThreadSafe<Pipeline<R>> {

{
std::scoped_lock lock(queue_mutex_);

if (queue_.empty()) {
// Items were removed from queue in Clear after available_ was
// signalled.
return PipelineConsumeResult::NoneAvailable;
}
std::tie(resource, trace_id) = std::move(queue_.front());
queue_.pop_front();
items_count = queue_.size();
Expand All @@ -171,6 +177,12 @@ class Pipeline : public fml::RefCountedThreadSafe<Pipeline<R>> {
: PipelineConsumeResult::Done;
}

/// Remove all items from the queue.
void Clear() {
std::scoped_lock lock(queue_mutex_);
queue_.clear();
}

private:
const uint32_t depth_;
fml::Semaphore empty_;
Expand Down
9 changes: 6 additions & 3 deletions shell/common/shell_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,12 @@ TEST_F(ShellTest,
auto end_frame_callback =
[&](bool should_resubmit_frame,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
ASSERT_TRUE(raster_thread_merger.get() != nullptr);
ASSERT_TRUE(should_resubmit_frame);
end_frame_called = true;
// The asserts below are only valid until DestroyShell is called
if (!end_frame_called) {
ASSERT_TRUE(raster_thread_merger.get() != nullptr);
ASSERT_TRUE(should_resubmit_frame);
end_frame_called = true;
}
end_frame_latch.Signal();
};
auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
Expand Down