<?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>250548</bug_id>
          
          <creation_ts>2023-01-13 00:19:29 -0800</creation_ts>
          <short_desc>Excessive &apos;timeupdate&apos; events triggered by video element with HLS streams carrying in-band EMSG metadata</short_desc>
          <delta_ts>2023-01-20 09:40:23 -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>Safari 16</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 13</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>250741</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>jameson.steiner</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>jameson.steiner</cc>
    
    <cc>jer.noble</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1925261</commentid>
    <comment_count>0</comment_count>
      <attachid>464479</attachid>
    <who name="">jameson.steiner</who>
    <bug_when>2023-01-13 00:19:29 -0800</bug_when>
    <thetext>Created attachment 464479
HTML page loading an HLS stream carrying EMSG metadata into a video element and enabling the metadata track. Logging out &apos;timeupdate&apos; events during playback to observe the issue.

When playing HLS streams carrying EMSG in-band metadata, excessive/duplicate &apos;timeupdate&apos; events would be fired by the video element if the respective metadata track is enabled.

Observations:
1. If the metadata track&apos;s &apos;mode&apos; property is set to &apos;disabled&apos; (default) the browser does not process the track at all as per the API spec and &apos;timeupdate&apos; events from the video element are observed in normal 250ms intervals.
2. Once the track is enabled by setting its mode to &apos;hidden&apos;, excessive &apos;timeupdate&apos; events are triggered by the video element. Looking at the timing of the events it looks like some of them are triggered at the exact same time, i.e. are duplicates.

This causes event handlers on the &apos;timeupdate&apos; event to be called more often and thereby also causes more load on the device. In the attached reproduction case, around twice as many events are fired if the metadata track is enabled. Furthermore, with a stream of one of our customers that also carries a lot of EMSG metadata (but we cannot share publically), we are seeing around 750 &apos;timeupdate&apos; events within a 10-second period of playback if the metadata track is enabled vs. 40 events if the track is disabled. Additionally, with that stream, we are seeing CPU utilization and memory consumption steadily rising during playback up to a point (after around 1 hr) that Safari shows a banner saying &quot;This web page is using significant memory. Closing it may improve the responsiveness of your Mac.&quot; and the page becomes very unresponsive. This is also only observed if the metadata track is enabled.

Reproduction case:
Attached is a simple HTML page loading an HLS stream that carries EMSG metadata into a video element and enabling the metadata track. Start playback and observe logged &apos;timeupdate&apos; events in the browser console during playback. After 15 seconds playback is finished and the total count of received &apos;timeupdate&apos; events is logged out. Different behavior can be observed depending on whether the metadata track is enabled or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926156</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-01-17 17:34:06 -0800</bug_when>
    <thetext>Marking this as duplicate to bug 250741, where I will fix it after discussing this with Eric.

*** This bug has been marked as a duplicate of bug 250741 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926934</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-01-20 09:40:23 -0800</bug_when>
    <thetext>Just to confirm, I built WebKit from Trunk (today - so the patch has already landed) and run the testcase in mini browser and observed via Console and there is no duplicate event and there were 60 total time update event in Console.

https://bug-250548-attachments.webkit.org/attachment.cgi?id=464479:22:17: CONSOLE WARN 2023-01-20T17:37:57.947Z - ended fired, got 60 timeupdate events in total


So I think the duplicate issue seems to be fixed now after bug bug 250741. Thanks!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>464479</attachid>
            <date>2023-01-13 00:19:29 -0800</date>
            <delta_ts>2023-01-13 00:19:29 -0800</delta_ts>
            <desc>HTML page loading an HLS stream carrying EMSG metadata into a video element and enabling the metadata track. Logging out &apos;timeupdate&apos; events during playback to observe the issue.</desc>
            <filename>hls-video-element.html</filename>
            <type>text/html</type>
            <size>1139</size>
            <attacher>jameson.steiner</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgICA8bWV0YSBjaGFyc2V0
PSJVVEYtOCI+CiAgICA8bWV0YSBodHRwLWVxdWl2PSJYLVVBLUNvbXBhdGlibGUiIGNvbnRlbnQ9
IklFPWVkZ2UiPgogICAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmlj
ZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xLjAiPgogICAgPHRpdGxlPkRvY3VtZW50PC90aXRsZT4K
PC9oZWFkPgo8Ym9keT4KICAgIDx2aWRlbyBoZWlnaHQ9NzIwIGNvbnRyb2xzIG11dGVkPjwvdmlk
ZW8+CjwvYm9keT4KPHNjcmlwdD4KICBsZXQgdGltZVVwZGF0ZUNvdW50ID0gMDsKICBjb25zdCB2
aWRlbyA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoJ3ZpZGVvJyk7CgogIHZpZGVvLmFkZEV2ZW50
TGlzdGVuZXIoJ3RpbWV1cGRhdGUnLCAoZSkgPT4gewogICAgdGltZVVwZGF0ZUNvdW50Kys7CiAg
ICBjb25zb2xlLndhcm4oYCR7bmV3IERhdGUoKS50b0lTT1N0cmluZygpfSAtIHRpbWV1cGRhdG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