<?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>237323</bug_id>
          
          <creation_ts>2022-03-01 07:12:12 -0800</creation_ts>
          <short_desc>Occasional issue with pause from the play promise not working</short_desc>
          <delta_ts>2022-10-01 14:19:57 -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>Media</component>
          <version>Safari 15</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Derk-Jan Hartman">hartman.wiki</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>jer.noble</cc>
    
    <cc>supersonicandtails</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1847016</commentid>
    <comment_count>0</comment_count>
    <who name="Derk-Jan Hartman">hartman.wiki</who>
    <bug_when>2022-03-01 07:12:12 -0800</bug_when>
    <thetext>I&apos;m experiencing an occasional issue with the pause() command of &lt;audio&gt; elements not functioning...

Codepen example: https://codepen.io/hartman/pen/ZEameXW?editors=1111

The reproduction conditions are as follows:
1. The audio sample needs to be supported by the device. MP3 qualifies.
2. The audio sample uses preload=&quot;none&quot;
3. The audio sample is played.
4. The audio sample is paused from the promise of the play
5. The audio sample keeps playing, even thought the pause() was sent.

Things I have noticed:
1. I can only trigger it on the initial playback when first opening the page. This might indicate that the load phase is very important, once in the resource cache, I can no longer trigger it (play not delayed because of the load?)
2. The load phase is probably also why preload=&quot;none&quot; is a good trigger for this.
3. I&apos;ve only been able to reproduce with mp3, but this might be a coincidence as I haven&apos;t tested a lot of mp4.
4. This happens quite often, say 1 in 10 or 1 in 20 or so playbacks, but definitely not all the time.
5. My older hardware like my 2015 MacBook Pro and my iPhone SE seem to trigger it more easily than my new 2021 MacBook Pro for instance, again indicating something about a racecondition due to performance.
6. Similarly, my reduced testcase on codepen seems to trigger this left often then a full blown website like https://commons.wikimedia.org/wiki/File:Armstrong_Small_Step.ogg (if this fails, you might hear the audio clip being played twice, until I have applied the workaround to production).
7. Wrapping the pause inside the play promise with a setTimeout, kicking it to the next cycle, also seems to fix this behaviour.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1847017</commentid>
    <comment_count>1</comment_count>
    <who name="Derk-Jan Hartman">hartman.wiki</who>
    <bug_when>2022-03-01 07:13:13 -0800</bug_when>
    <thetext>Linking back to Wikimedia issue: https://phabricator.wikimedia.org/T301740</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1849248</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-03-08 07:13:15 -0800</bug_when>
    <thetext>&lt;rdar://problem/89966322&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1902641</commentid>
    <comment_count>3</comment_count>
      <attachid>462751</attachid>
    <who name="Peter Fernandes">supersonicandtails</who>
    <bug_when>2022-10-01 14:19:57 -0700</bug_when>
    <thetext>Created attachment 462751
Demonstrates Safari seemingly unpausing an audio element on its own

I believe I have a self-contained test case that reproduces the &quot;audio playing twice&quot; issue after an initial audio element is paused.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>462751</attachid>
            <date>2022-10-01 14:19:57 -0700</date>
            <delta_ts>2022-10-01 14:19:57 -0700</delta_ts>
            <desc>Demonstrates Safari seemingly unpausing an audio element on its own</desc>
            <filename>audio-pause.html</filename>
            <type>text/html</type>
            <size>1072</size>
            <attacher name="Peter Fernandes">supersonicandtails</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+Cgk8bWV0YSBjaGFyc2V0PSJV
VEYtOCI+Cgk8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRo
LCBpbml0aWFsLXNjYWxlPTEuMCI+Cgk8dGl0bGU+RG9jdW1lbnQ8L3RpdGxlPgo8L2hlYWQ+Cjxi
b2R5PgoJPG9sPgoJCTxsaT5DbGljayBwbGF5LCB3YWl0IGZvciBhdWRpbyB0byBzdGFydDwvbGk+
CgkJPGxpPkNsaWNrIHBsYXkgYWdhaW4sIHF1aWNrbHkgc3dpdGNoIHRvIGFub3RoZXIgYnJvd3Nl
ciB0YWI8L2xpPgoJCTxsaT5XYWl0IGZvciBhdWRpbyB0byBzdGFydCBhIHNlY29uZCB0aW1lPC9s
aT4KCQk8bGk+U3dpdGNoIGJhY2sgdG8gdGhpcyBwYWdlJ3MgdGFiPC9saT4KCQk8bGk+Q2xpY2sg
cGxheSBhZ2FpbiwgcXVpY2tseSBzd2l0Y2ggdG8gYW5vdGhlciBicm93c2VyIHRhYjwvbGk+CgkJ
PGxpPldhaXQgZm9yIGF1ZGlvIHRvIHN0YXJ0IGFnYWluPC9saT4KCQk8bGk+U3dpdGNoIGJhY2sg
dG8gdGhpcyBwYWdlJ3MgdGFiPC9saT4KCTwvb2w+Cgk8YnV0dG9uIHR5cGU9ImJ1dHRvbiIgaWQ9
InBsYXktYnV0dG9uIj5QbGF5PC9idXR0b24+Cgk8c2NyaXB0PgoJCWxldCBjdXJBdWRpbyA9IG51
bGw7CgoJCWZ1bmN0aW9uIHBsYXlOZXh0VHJhY2tBZnRlckRlbGF5KCkKC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