<?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>226163</bug_id>
          
          <creation_ts>2021-05-23 23:31:36 -0700</creation_ts>
          <short_desc>SFSafariViewController pauses media playback while in background</short_desc>
          <delta_ts>2021-06-24 10:38:38 -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 14</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 14</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="Teodor">teodor.atroshenko</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>eric.carlson</cc>
    
    <cc>jer.noble</cc>
    
    <cc>peng.liu6</cc>
    
    <cc>smoley</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1763039</commentid>
    <comment_count>0</comment_count>
    <who name="Teodor">teodor.atroshenko</who>
    <bug_when>2021-05-23 23:31:36 -0700</bug_when>
    <thetext>- User opens an app, which loads a site in SFSafariViewController
- Site makes use of WebRTC, plays remote media in a &lt;video&gt; element, and uses WebSocket for connecting to the control server
- User returns to home screen (aka app with SFSafariViewController goes into background)
- User spends anywhere from seconds to a minute away from the app (e.g., writes a text message, dismisses a notification, rejects an incoming call, takes a photo)
- User returns to the app with SFSafariViewController

Expected:
- Remote streams are playing
- Signaling channel is open
- JS code ran unthrottled in the background
- (Extended goal) If camera/microphone was not used by any other app, their streams have not &quot;ended&quot; while the app is in the background, the behavior currently seen in WKWebView, Safari, or a site open as home screen app.

Actual:
- Remote streams (&lt;video&gt; elements) may be stuck on black screen
- RTCPeerConnections may have been killed
- Signaling (WebSocket) connection is likely killed within ~30 seconds away from the app
- While app was in background, no audio was being played beyond ~1 second after minimizing the app (Control Center shows the site &lt;title&gt; with active playback for 1 second after minimizing, then it clears to &quot;no playback&quot; state)
- Camera and microphone streams have &quot;ended&quot; and new getUserMedia call has to be made

This can also be (partially) reproduced with a simple page playing &lt;audio&gt;. When SFSafariViewController is taken to the background, playback is stopped.

It seems to have always been the case, so no regression here. The behavior is unexpected, however, and requires iOS-specific code for handling (sometimes partially) broken state.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1763546</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-05-25 09:53:39 -0700</bug_when>
    <thetext>&lt;rdar://problem/78462486&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1772354</commentid>
    <comment_count>2</comment_count>
    <who name="Smoley">smoley</who>
    <bug_when>2021-06-24 10:38:38 -0700</bug_when>
    <thetext>Thanks for filing Teodor. Is there a test app available?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>