Skip to content

Commit

Permalink
wpe: Clean up pending transactions on exit
Browse files Browse the repository at this point in the history
Cleanup pending transactions on exit to avoid crash
  • Loading branch information
zhani committed Mar 9, 2024
1 parent a8f87e9 commit ecb4b47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
11 changes: 10 additions & 1 deletion wpe/src/main/cpp/Browser/RendererSurfaceControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ RendererSurfaceControl::RendererSurfaceControl(WPEAndroidViewBackend* viewBacken
Logging::logDebug("RendererSurfaceControl(%p, %u, %u)", m_viewBackend, m_size.m_width, m_size.m_height);
}

RendererSurfaceControl::~RendererSurfaceControl() { Logging::logDebug("RendererSurfaceControl()"); }
RendererSurfaceControl::~RendererSurfaceControl()
{
Logging::logDebug("~RendererSurfaceControl()");
while (!m_pendingTransactionQueue.empty()) {
m_pendingTransactionQueue.front().setParent(*m_surface, nullptr);
m_pendingTransactionQueue.front().apply();
m_pendingTransactionQueue.pop();
m_numTransactionCommitOrAckPending--;
}
}

void RendererSurfaceControl::onSurfaceCreated(ANativeWindow* window) noexcept
{
Expand Down
6 changes: 6 additions & 0 deletions wpe/src/main/cpp/Browser/SurfaceControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ void SurfaceControl::Transaction::setBuffer(const Surface& surface, AHardwareBuf
ASurfaceTransaction_setBuffer(m_transaction, surface.surfaceControl(), buffer, fenceFD);
}

void SurfaceControl::Transaction::setParent(const Surface& surface, Surface* newParent)
{
ASurfaceTransaction_reparent(
m_transaction, surface.surfaceControl(), newParent != nullptr ? newParent->surfaceControl() : nullptr);
}

void SurfaceControl::Transaction::setOnCompleteCallback(OnCompleteCallback callback)
{
m_onCompleteCallback = std::move(callback);
Expand Down
1 change: 1 addition & 0 deletions wpe/src/main/cpp/Browser/SurfaceControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class SurfaceControl final {
void setVisibility(const Surface& surface, int8_t visibility);
void setZOrder(const Surface& surface, int32_t zOrder);
void setBuffer(const Surface& surface, AHardwareBuffer* buffer, int fenceFD);
void setParent(const Surface& surface, Surface* newParent);

void apply();

Expand Down

0 comments on commit ecb4b47

Please sign in to comment.