<?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>244008</bug_id>
          
          <creation_ts>2022-08-16 14:04:36 -0700</creation_ts>
          <short_desc>Leak of id&lt;MTLArgumentEncoder&gt; in rx::(anonymous)::InitArgumentBufferEncoder()</short_desc>
          <delta_ts>2022-08-18 03:48:51 -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>ANGLE</component>
          <version>Other</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>218877</dependson>
    
    <dependson>219260</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="David Kilzer (:ddkilzer)">ddkilzer</assigned_to>
          <cc>dino</cc>
    
    <cc>kbr</cc>
    
    <cc>kkinnunen</cc>
    
    <cc>kpiddington</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1891753</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2022-08-16 14:04:36 -0700</bug_when>
    <thetext>Leak of id&lt;MTLArgumentEncoder&gt; in rx::(anonymous)::InitArgumentBufferEncoder().

The struct is defined like this in ProgramMtl.h:

```
struct ProgramArgumentBufferEncoderMtl
{
    void reset(ContextMtl *contextMtl);

    mtl::AutoObjCPtr&lt;id&lt;MTLArgumentEncoder&gt;&gt; metalArgBufferEncoder;
    mtl::BufferPool bufferPool;
};
```

However the method doesn&apos;t adopt the object in ProgramMtl.mm, which causes it to be assigned with a +2 retain count:

```
void InitArgumentBufferEncoder(mtl::Context *context,
                               id&lt;MTLFunction&gt; function,
                               uint32_t bufferIndex,
                               ProgramArgumentBufferEncoderMtl *encoder)
{
    encoder-&gt;metalArgBufferEncoder = [function newArgumentEncoderWithBufferIndex:bufferIndex];   // LEAK!
    if (encoder-&gt;metalArgBufferEncoder)
    {
        encoder-&gt;bufferPool.initialize(context, encoder-&gt;metalArgBufferEncoder.get().encodedLength,
                                       mtl::kArgumentBufferOffsetAlignment, 0);
    }
}
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891755</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-08-16 14:05:06 -0700</bug_when>
    <thetext>&lt;rdar://problem/98747531&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891756</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2022-08-16 14:07:06 -0700</bug_when>
    <thetext>This regressed in commit 6b271237a02594f551ab5948d7d2951addfda81f (232042@main) on Dec 02, 2020.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891768</commentid>
    <comment_count>3</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2022-08-16 14:43:47 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/3380</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891983</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-08-17 11:14:06 -0700</bug_when>
    <thetext>Committed 253525@main (06f230986084): &lt;https://commits.webkit.org/253525@main&gt;

Reviewed commits have been landed. Closing PR #3380 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892180</commentid>
    <comment_count>5</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2022-08-18 03:48:51 -0700</bug_when>
    <thetext>https://chromium-review.googlesource.com/c/angle/angle/+/3834820</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>