<?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>265718</bug_id>
          
          <creation_ts>2023-12-02 04:57:05 -0800</creation_ts>
          <short_desc>[GPUP] Remove TrackPrivateRemoteIdentifier, fix memory leak</short_desc>
          <delta_ts>2023-12-06 01:53:31 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=242925</see_also>
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jean-Yves Avenard [:jya]">jean-yves.avenard</reporter>
          <assigned_to name="Jean-Yves Avenard [:jya]">jean-yves.avenard</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1996434</commentid>
    <comment_count>0</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2023-12-02 04:57:05 -0800</bug_when>
    <thetext>following bug 254099; we are no longer using AtomString as track identifier and as such we no longer need the `TrackPrivateRemoteIdentifier` to bridge the TrackPrivate living in the GPU Process to those in the web content process, instead simply using their TrackID (an uint64_t).

While in the process of performing this task, I identify a leak in the `MediaPlayerPrivateRemote` code, which was only partially fixed in bug 242925

Whenever a new init segment is parsed by a sourceBuffer in the GPU Process (through the SourceBufferParser); a new TrackPrivate is created and stored in the `InitializationSegment`

When the SourceBufferPrivate call the SourceBufferPrivateClient, the `RemoteSourceBufferProxy` will create a new `RemoteVideoTrackProxy` [1]
This is done by `RemoteMediaPlayerProxy::addRemote[Video|Audio|Text]TrackProxy`, which will check of the track id is already existing, and if so will overwrite it with the new TrackPrivate [2]
But regardless of the preview tack id, a `Remote[Video|Audio|Text]TrackProxy` will be created, with a new, unique TrackPrivateRemoteIdentifier [3] which will then create the RemoteVideoTrack/RemoteAudioTrack/RemoteTextTrack in the content process [4]
The code there ensure that the existing RemoteTrack with this unique TrackPrivateRemoteIdentifier doesn&apos;t exist and will create a new one.

This RemoteTrack will never be deleted, it just becomes unused as the corresponding TrackPrivate in the GPU Process got deleted.

[1] https://searchfox.org/wubkat/rev/02b2f8b7a253140d82f59e38a68257431139d2e7/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp#88,97,106
[2] https://searchfox.org/wubkat/rev/02b2f8b7a253140d82f59e38a68257431139d2e7/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp#637-643
[3] https://searchfox.org/wubkat/rev/02b2f8b7a253140d82f59e38a68257431139d2e7/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp#645-647
[4] https://searchfox.org/wubkat/rev/02b2f8b7a253140d82f59e38a68257431139d2e7/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp#762-764</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996435</commentid>
    <comment_count>1</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2023-12-02 04:58:19 -0800</bug_when>
    <thetext>[press saved to quickly] bug 242925 identify the issue, but all it did was removed the TrackPrivate from the GPU process, not the corresponding TrackPrivateRemote in the content process.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996436</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-12-02 04:58:39 -0800</bug_when>
    <thetext>&lt;rdar://problem/119070875&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996437</commentid>
    <comment_count>3</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2023-12-02 05:10:10 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/21207</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1997339</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-12-06 01:52:48 -0800</bug_when>
    <thetext>Committed 271599@main (e0a0bc967262): &lt;https://commits.webkit.org/271599@main&gt;

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

    </bug>

</bugzilla>