Skip to content

Commit

Permalink
Remove view backend bridge association on connection drops
Browse files Browse the repository at this point in the history
Arrange for calling ViewBackend::unregisterSurface() also when a Surface
is destroyed. This is a no-op if the nested compositor had the chance
to receive and handle a FdoIPC::UnregisterSurface message before the
surface is destroyed; but allows undoing the bridge association when the
Wayland client connection is closed beforehand. The destruction callback
for the surface is guaranteed to always be called by libwayland, even
on dropped connections, to allow cleaning up reagardless of the fate
of its clients.

Among others, this covers the case in which a WPEWebProcess is abruptly
exited, for example due to a crash or a top-level resource load being
blocked by a content filter.

Co-authored-by: Adrian Perez de Castro <[email protected]>
Acked-by: Adrian Perez de Castro <[email protected]>
Signed-off-by: Pablo Saavedra <[email protected]>
(cherry picked from commit 4e64c8d)
  • Loading branch information
psaavedra authored and aperezdc committed May 12, 2021
1 parent 007a285 commit a01f2c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/view-backend-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class ViewBackend final : public WS::APIClient, public FdoIPC::MessageReceiver {
void exportLinuxDmabuf(const struct linux_dmabuf_buffer *dmabuf_buffer) override;
void exportShmBuffer(struct wl_resource* bufferResource, struct wl_shm_buffer* shmBuffer) override;
void exportEGLStreamProducer(struct wl_resource*) override;

void bridgeConnectionLost(uint32_t id) override
{
unregisterSurface(id);
}

void dispatchFrameCallbacks();
void releaseBuffer(struct wl_resource* buffer_resource);

Expand Down
5 changes: 4 additions & 1 deletion src/ws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,11 @@ void Instance::unregisterSurface(Surface* surface)
[surface](const std::pair<uint32_t, Surface*>& value) -> bool {
return value.second == surface;
});
if (it != m_viewBackendMap.end())
if (it != m_viewBackendMap.end()) {
m_viewBackendMap.erase(it);
if (surface->apiClient)
surface->apiClient->bridgeConnectionLost(it->first);
}
}

void Instance::dispatchFrameCallbacks(uint32_t bridgeId)
Expand Down
6 changes: 6 additions & 0 deletions src/ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ struct APIClient {
virtual void exportLinuxDmabuf(const struct linux_dmabuf_buffer *dmabuf_buffer) = 0;
virtual void exportShmBuffer(struct wl_resource*, struct wl_shm_buffer*) = 0;
virtual void exportEGLStreamProducer(struct wl_resource*) = 0;

// Invoked when the association with the surface associated with a given
// wpe_bridge identifier is no longer valid, typically due to the nested
// compositor client being disconnected before having the chance to read
// and process a FdoIPC::UnregisterSurface message.
virtual void bridgeConnectionLost(uint32_t bridgeId) = 0;
};

struct Surface {
Expand Down

0 comments on commit a01f2c0

Please sign in to comment.