Bug 1875528 - Part 2: Break the strong reference cycle between WebGPUChild and CanvasManagerChild, r=webgpu-reviewers,nical

The strong reference from CanvasManagerChild to WebGPUChild was never cleared
when the WebGPUChild dies, meaning that it would form a strong cycle through
the `Manager()` reference.

Under the new system, the WebGPUChild actor is kept alive by the IPC
connection, and will be torn down when the IPC connection dies.

Differential Revision: https://phabricator.services.mozilla.com/D198625
This commit is contained in:
Nika Layzell 2024-04-22 17:13:23 +00:00
parent 1b28f9f085
commit f3ebfed97b
2 changed files with 7 additions and 7 deletions

View file

@ -207,14 +207,15 @@ RefPtr<layers::CanvasChild> CanvasManagerChild::GetCanvasChild() {
}
RefPtr<webgpu::WebGPUChild> CanvasManagerChild::GetWebGPUChild() {
if (!mWebGPUChild) {
mWebGPUChild = MakeAndAddRef<webgpu::WebGPUChild>();
if (!SendPWebGPUConstructor(mWebGPUChild)) {
mWebGPUChild = nullptr;
}
if (PWebGPUChild* actor = LoneManagedOrNullAsserts(ManagedPWebGPUChild())) {
return static_cast<webgpu::WebGPUChild*>(actor);
}
return mWebGPUChild;
auto actor = MakeRefPtr<webgpu::WebGPUChild>();
if (!SendPWebGPUConstructor(actor)) {
return nullptr;
}
return actor;
}
layers::ActiveResourceTracker* CanvasManagerChild::GetActiveResourceTracker() {

View file

@ -68,7 +68,6 @@ class CanvasManagerChild final : public PCanvasManagerChild {
RefPtr<mozilla::dom::ThreadSafeWorkerRef> mWorkerRef;
RefPtr<layers::CanvasChild> mCanvasChild;
RefPtr<webgpu::WebGPUChild> mWebGPUChild;
UniquePtr<layers::ActiveResourceTracker> mActiveResourceTracker;
const uint32_t mId;
bool mActive = true;