<?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>187445</bug_id>
          
          <creation_ts>2018-07-08 02:26:38 -0700</creation_ts>
          <short_desc>Video hides when on last frame and changing page visibility</short_desc>
          <delta_ts>2019-08-19 16:07:15 -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 11</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.13</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</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="Tom Bigelajzen">tombigel</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>jer.noble</cc>
    
    <cc>peng.liu6</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1440210</commentid>
    <comment_count>0</comment_count>
      <attachid>344542</attachid>
    <who name="Tom Bigelajzen">tombigel</who>
    <bug_when>2018-07-08 02:26:38 -0700</bug_when>
    <thetext>Created attachment 344542
demo to reproduce bug

To reproduce:
1. Play an mp4 video in Safari (tested on MacOS 10.13, Safari 11 and Safari 12 Preview) 
2. Wait for the video to end and show last frame
3. Switch tab or application window (trigger a visibilitychange &quot;hidden&quot; event)
4. Switch back to the video tab

Result:
The video disappears from the page view
- The video is still in the dom and still interactive.
- Any change to the video - seeking, playing etc shows the video again

Notes:
While playing with this I noticed the last frame of the video is a point of inconsistent behaviour - 
Skip to last frame while playing and the video view freezes in current frame, sometimes it skips to &quot;almost&quot; the last frame, sometimes the video disappears while skipping to the last frame.
Should be investigated a bit more and worth another bug if there isn&apos;t any.

see attached html file, online codepen version here - https://codepen.io/tombigel/pen/BVXVpX</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1441036</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-07-10 17:30:39 -0700</bug_when>
    <thetext>&lt;rdar://problem/42049015&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1562829</commentid>
    <comment_count>2</comment_count>
    <who name="Peng Liu">peng.liu6</who>
    <bug_when>2019-08-19 16:07:15 -0700</bug_when>
    <thetext>On Safari Technology Preview release 89, this bug is not reproducible. The last video frame will always be there when we switch tab or application window back and forth.

About the inconsistent behavior of skipping to the last frame, I can only reproduce the inconsistency with some long video files, e.g., the big Bucky bunny video whose duration is almost 10 minutes. For short videos (~10s), the skipping to the last frame is always showing the last frame.

I would suggest implementing the skipping to the last frame by setting the currentTime attribute of the video element to a value which is little smaller than the duration.
Example code is below:
==================================================================
// This line will only work consistently when the video file is very short (~10 seconds)
skip.addEventListener(&apos;click&apos;, () =&gt; video.currentTime = video.duration)

// Below line will always skip to the last frame
skip.addEventListener(&apos;click&apos;, () =&gt; video.currentTime = video.duration - 0.01)
==================================================================</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>344542</attachid>
            <date>2018-07-08 02:26:38 -0700</date>
            <delta_ts>2018-07-08 02:26:38 -0700</delta_ts>
            <desc>demo to reproduce bug</desc>
            <filename>safari-last-frame.html</filename>
            <type>text/html</type>
            <size>1645</size>
            <attacher name="Tom Bigelajzen">tombigel</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sI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