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

Commit 5f58e4d

Browse files
committed
Fix backpressure waits.
1 parent 8eea9ee commit 5f58e4d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

impeller/renderer/backend/vulkan/swapchain/ahb/ahb_swapchain_vk.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ std::shared_ptr<AHBSurfaceVK> AHBSwapchainVK::CreateNewSurface() {
134134
std::shared_ptr<Surface> AHBSwapchainVK::AcquireNextDrawable() {
135135
TRACE_EVENT0("impeller", __FUNCTION__);
136136

137-
Lock lock(mutex_);
138-
139137
{
140138
TRACE_EVENT0("impeller", "CompositorBackpressure");
141139
// Accompanying signal is in the call to recycle the surface after the
@@ -146,6 +144,8 @@ std::shared_ptr<Surface> AHBSwapchainVK::AcquireNextDrawable() {
146144
}
147145
}
148146

147+
Lock lock(mutex_);
148+
149149
if (auto surface = PopRecyclable()) {
150150
FML_LOG(IMPORTANT) << "Recycled surface.";
151151
return surface;
@@ -204,8 +204,10 @@ bool AHBSwapchainVK::PresentSurface(
204204

205205
void AHBSwapchainVK::OnSurfaceDidCompleteBeingUsedByCompositor(
206206
std::shared_ptr<AHBSurfaceVK> surface) {
207-
Lock lock(mutex_);
208-
PushRecyclable(std::move(surface));
207+
{
208+
Lock lock(mutex_);
209+
PushRecyclable(std::move(surface));
210+
}
209211
drawable_count_sema_.Signal();
210212
}
211213

impeller/renderer/backend/vulkan/swapchain/ahb/ahb_swapchain_vk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class AHBSwapchainVK final
6565
std::weak_ptr<Context> context_;
6666
std::shared_ptr<android::NativeWindow> native_window_;
6767
std::shared_ptr<android::SurfaceControl> surface_control_;
68+
fml::Semaphore drawable_count_sema_;
6869
mutable Mutex mutex_;
69-
fml::Semaphore drawable_count_sema_ IPLR_GUARDED_BY(mutex_);
7070
android::HardwareBufferDescriptor desc_ IPLR_GUARDED_BY(mutex_);
7171
std::deque<Recyclable> recyclable_ IPLR_GUARDED_BY(mutex_);
7272
bool is_valid_ = false;

0 commit comments

Comments
 (0)