@@ -101,7 +101,8 @@ void CommandEncoder::Cleanup() {
101101
102102RefPtr<WebGPUChild> CommandEncoder::GetBridge () { return mBridge ; }
103103
104- void CommandEncoder::TrackPresentationContext (CanvasContext* aTargetContext) {
104+ void CommandEncoder::TrackPresentationContext (
105+ WeakPtr<CanvasContext> aTargetContext) {
105106 if (aTargetContext) {
106107 mPresentationContexts .AppendElement (aTargetContext);
107108 }
@@ -302,7 +303,8 @@ void CommandEncoder::ResolveQuerySet(QuerySet& aQuerySet, uint32_t aFirstQuery,
302303 mBridge ->SendCommandEncoderAction (mId , mParent ->mId , std::move (bb));
303304}
304305
305- void CommandEncoder::EndComputePass (ffi::WGPURecordedComputePass& aPass) {
306+ void CommandEncoder::EndComputePass (ffi::WGPURecordedComputePass& aPass,
307+ CanvasContextArray& aCanvasContexts) {
306308 // Because this can be called during child Cleanup, we need to check
307309 // that the bridge is still alive.
308310 if (!mBridge || !mBridge ->CanSend ()) {
@@ -316,12 +318,17 @@ void CommandEncoder::EndComputePass(ffi::WGPURecordedComputePass& aPass) {
316318 }
317319 mState = CommandEncoderState::Open;
318320
321+ for (const auto & context : aCanvasContexts) {
322+ TrackPresentationContext (context);
323+ }
324+
319325 ipc::ByteBuf byteBuf;
320326 ffi::wgpu_compute_pass_finish (&aPass, ToFFI (&byteBuf));
321327 mBridge ->SendComputePass (mId , mParent ->mId , std::move (byteBuf));
322328}
323329
324- void CommandEncoder::EndRenderPass (ffi::WGPURecordedRenderPass& aPass) {
330+ void CommandEncoder::EndRenderPass (ffi::WGPURecordedRenderPass& aPass,
331+ CanvasContextArray& aCanvasContexts) {
325332 // Because this can be called during child Cleanup, we need to check
326333 // that the bridge is still alive.
327334 if (!mBridge || !mBridge ->CanSend ()) {
@@ -335,6 +342,10 @@ void CommandEncoder::EndRenderPass(ffi::WGPURecordedRenderPass& aPass) {
335342 }
336343 mState = CommandEncoderState::Open;
337344
345+ for (const auto & context : aCanvasContexts) {
346+ TrackPresentationContext (context);
347+ }
348+
338349 ipc::ByteBuf byteBuf;
339350 ffi::wgpu_render_pass_finish (&aPass, ToFFI (&byteBuf));
340351 mBridge ->SendRenderPass (mId , mParent ->mId , std::move (byteBuf));
0 commit comments