<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>312228</bug_id>
          
          <creation_ts>2026-04-13 19:49:36 -0700</creation_ts>
          <short_desc>GPU process leaks RemoteRenderingBackend due to retain cycle with RemoteDisplayListRecorder and RemoteSnapshotRecorder maps</short_desc>
          <delta_ts>2026-04-14 04:32:26 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Compositing</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>282664</dependson>
    
    <dependson>297727</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="David Kilzer (:ddkilzer)">ddkilzer</assigned_to>
          <cc>kkinnunen</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2200012</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2026-04-13 19:49:36 -0700</bug_when>
    <thetext>`RemoteRenderingBackend::workQueueUninitialize()` clears `m_remoteImageBuffers` and `m_remoteImageBufferSets` but not `m_remoteDisplayListRecorders` or `m_remoteSnapshotRecorders`. Each `RemoteDisplayListRecorder` (via its `RemoteGraphicsContext` base class) holds a `Ref&lt;RemoteRenderingBackend&gt;`, forming a retain cycle through the `ScopedActiveMessageReceiveQueue` wrappers in the HashMap:

Backend -&gt; `m_remoteDisplayListRecorders` -&gt; `ScopedActiveMessageReceiveQueue` -&gt; `RemoteDisplayListRecorder` -&gt; `Ref&lt;RemoteRenderingBackend&gt;` -&gt; Backend

When `GPUConnectionToWebProcess::releaseRenderingBackend()` destroys the backend&apos;s `ScopedActiveMessageReceiveQueue`, `stopListeningForIPC()` calls `workQueueUninitialize()`. Because the display list recorder and snapshot recorder maps are not cleared, the remaining `Ref` back-references prevent the backend&apos;s reference count from reaching zero. The backend, its `StreamServerConnection`, `StreamConnectionWorkQueue`, and all unsunk recorders are leaked.

The `m_remoteDisplayListRecorders` map was introduced in Bug 297727 (299747@main) and `m_remoteSnapshotRecorders` in Bug 282664 (300358@main). Neither commit added the corresponding `clear()` call in `workQueueUninitialize()`, unlike the pre-existing `m_remoteImageBuffers` and `m_remoteImageBufferSets` maps which do have `clear()` calls.

The `leaks` tool on a memgraph of the GPU process directly identifies the cycle:

```
ROOT CYCLE: &lt;WebKit::RemoteRenderingBackend 0x...&gt; [448]
   ROOT CYCLE: &lt;non-object 0x...&gt; [320]
      ROOT CYCLE: &lt;WebKit::RemoteDisplayListRecorder 0x...&gt; [96]
         CYCLE BACK TO &lt;WebKit::RemoteRenderingBackend 0x...&gt;
```

The same pattern applies to `m_remoteSnapshotRecorders` via `RemoteSnapshotRecorder` -&gt; `RemoteGraphicsContext` -&gt; `Ref&lt;RemoteRenderingBackend&gt;`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2200013</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-04-13 19:49:43 -0700</bug_when>
    <thetext>&lt;rdar://problem/174706941&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2200022</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2026-04-13 20:18:56 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/62701</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2200155</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-14 04:32:23 -0700</bug_when>
    <thetext>Committed 311189@main (0de81382cce8): &lt;https://commits.webkit.org/311189@main&gt;

Reviewed commits have been landed. Closing PR #62701 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>