Bug 1783923 - Ensure WebRenderImageHost::OnReleased() is called during WebRenderBridgeParent shutdown r=gfx-reviewers,lsalzman

If WebRenderImageHost::OnReleased()  is called on all WebRenderImageHosts before RemoteTextureMap::Shutdown(), RemoteTextureMap does not own a reference of WebRenderImageHost during the shutdown.

On current gecko, when WebRenderImageHost is released by WebRenderBridgeParent::Destroy(), WebRenderImageHost::OnReleased() is not called. It needs to be addressed.

And RemoteTextureMap::Shutdown() need to be called after CompositorThreadHolder::Shutdown(). By it, we could expect that WebRenderBridgeParent::Destroy() is called on all WebRenderBridgeParents.

Differential Revision: https://phabricator.services.mozilla.com/D155673
This commit is contained in:
sotaro 2022-08-26 23:20:55 +00:00
parent 700d2d5ffb
commit 7e5059e7a3
4 changed files with 9 additions and 3 deletions

View File

@ -691,8 +691,8 @@ void GPUParent::ActorDestroy(ActorDestroyReason aWhy) {
// This could be running on either the Compositor or the Renderer
// thread.
CanvasManagerParent::Shutdown();
RemoteTextureMap::Shutdown();
CompositorThreadHolder::Shutdown();
RemoteTextureMap::Shutdown();
// There is a case that RenderThread exists when gfxVars::UseWebRender()
// is false. This could happen when WebRender was fallbacked to
// compositor.

View File

@ -412,6 +412,9 @@ void WebRenderBridgeParent::Destroy() {
mWebRenderBridgeRef->Clear();
mWebRenderBridgeRef = nullptr;
}
for (const auto& entry : mCompositables) {
entry.second->OnReleased();
}
mCompositables.clear();
ClearResources();
}

View File

@ -33,7 +33,10 @@ WebRenderImageHost::WebRenderImageHost(const TextureInfo& aTextureInfo)
ImageComposite(),
mCurrentAsyncImageManager(nullptr) {}
WebRenderImageHost::~WebRenderImageHost() { MOZ_ASSERT(mWrBridges.empty()); }
WebRenderImageHost::~WebRenderImageHost() {
MOZ_ASSERT(!mRemoteTextureConsumer);
MOZ_ASSERT(mWrBridges.empty());
}
void WebRenderImageHost::OnReleased() {
if (mRemoteTextureConsumer) {

View File

@ -1344,9 +1344,9 @@ void gfxPlatform::ShutdownLayersIPC() {
layers::ImageBridgeChild::ShutDown();
// This could be running on either the Compositor or the Renderer thread.
gfx::CanvasManagerParent::Shutdown();
RemoteTextureMap::Shutdown();
// This has to happen after shutting down the child protocols.
layers::CompositorThreadHolder::Shutdown();
RemoteTextureMap::Shutdown();
image::ImageMemoryReporter::ShutdownForWebRender();
// There is a case that RenderThread exists when UseWebRender() is
// false. This could happen when WebRender was fallbacked to compositor.