<?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>210555</bug_id>
          
          <creation_ts>2020-04-15 10:24:24 -0700</creation_ts>
          <short_desc>REGRESSION (r258977): Crash under Document::visibilityStateChanged</short_desc>
          <delta_ts>2020-04-15 11:54:19 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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>
          
          <blocked>208516</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>esprehn+autocc</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>kangil.han</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1641855</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2020-04-15 10:24:24 -0700</bug_when>
    <thetext>Crash under Document::visibilityStateChanged:
[  0] 0x0000000107974669 WebCore`WebCore::Document::visibilityStateChanged() + 409 at Document.cpp:1749
       1745	        client-&gt;visibilityStateChanged();
       1746	
       1747	#if ENABLE(MEDIA_STREAM)
       1748	    if (hidden()) {
    -&gt; 1749	        RealtimeMediaSourceCenter::singleton().setCapturePageState(hidden(), page()-&gt;isMediaCaptureMuted());
       1750	        return;
       1751	    }
       1752	#if PLATFORM(IOS_FAMILY)
       1753	    if (!PlatformMediaSessionManager::sharedManager().isInterrupted())</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641856</commentid>
    <comment_count>1</comment_count>
      <attachid>396546</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2020-04-15 10:25:51 -0700</bug_when>
    <thetext>Created attachment 396546
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641858</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2020-04-15 10:26:59 -0700</bug_when>
    <thetext>I am not quite sure how to write a test for this yet. If anybody has an idea, please let me know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641861</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2020-04-15 10:28:33 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #2)
&gt; I am not quite sure how to write a test for this yet. If anybody has an
&gt; idea, please let me know.

Looks like there is an internals.setPageVisibility() method. I will try that we a detached iframe document to see if it reproduces.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641866</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2020-04-15 10:51:56 -0700</bug_when>
    <thetext>Some JS event must get fired synchronously when Document::visibilityStateChanged() is called. The &quot;visibilitychange&quot; is fired asynchronously so I wasn&apos;t able to write a test based on this event. I believe a JS event (likely media related) gets fired synchronously and the event handler in JS removes one of the iframes from the document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641870</commentid>
    <comment_count>5</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-04-15 10:56:14 -0700</bug_when>
    <thetext>Could it be the muted event of a MediaStreamTrack?
On iOS, if document goes in the background, a video capture track gets muted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641872</commentid>
    <comment_count>6</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-04-15 10:58:07 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #5)
&gt; Could it be the muted event of a MediaStreamTrack?
&gt; On iOS, if document goes in the background, a video capture track gets muted.

Nope, since this would happen after the setCapturePageState call.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641874</commentid>
    <comment_count>7</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2020-04-15 11:05:10 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #6)
&gt; (In reply to youenn fablet from comment #5)
&gt; &gt; Could it be the muted event of a MediaStreamTrack?
&gt; &gt; On iOS, if document goes in the background, a video capture track gets muted.
&gt; 
&gt; Nope, since this would happen after the setCapturePageState call.

I don&apos;t think the order matters. Page::forEachDocument() gathers all the documents of the page in a Vector. Then iterates over this vector and calls Document::visibilityStateChanged() on each document. The first document is the top document.

So if the top document has an event listener for any event that gets called synchronously during Document::visibilityStateChanged() and if that event listener removes a subframe from the document then we would hit this crash when calling Document::visibilityStateChanged() for the subframe document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641893</commentid>
    <comment_count>8</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2020-04-15 11:38:20 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #7)
&gt; (In reply to youenn fablet from comment #6)
&gt; &gt; (In reply to youenn fablet from comment #5)
&gt; &gt; &gt; Could it be the muted event of a MediaStreamTrack?
&gt; &gt; &gt; On iOS, if document goes in the background, a video capture track gets muted.
&gt; &gt; 
&gt; &gt; Nope, since this would happen after the setCapturePageState call.
&gt; 
&gt; I don&apos;t think the order matters. Page::forEachDocument() gathers all the
&gt; documents of the page in a Vector. Then iterates over this vector and calls
&gt; Document::visibilityStateChanged() on each document. The first document is
&gt; the top document.
&gt; 
&gt; So if the top document has an event listener for any event that gets called
&gt; synchronously during Document::visibilityStateChanged() and if that event
&gt; listener removes a subframe from the document then we would hit this crash
&gt; when calling Document::visibilityStateChanged() for the subframe document.

HTMLMediaElement::visibilityStateChanged() gets called. Any idea if this can fire an event synchronously?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641903</commentid>
    <comment_count>9</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2020-04-15 11:53:07 -0700</bug_when>
    <thetext>Committed r260142: &lt;https://trac.webkit.org/changeset/260142&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396546.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641904</commentid>
    <comment_count>10</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-04-15 11:54:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/61840165&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>396546</attachid>
            <date>2020-04-15 10:25:51 -0700</date>
            <delta_ts>2020-04-15 11:53:08 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-210555-20200415102550.patch</filename>
            <type>text/plain</type>
            <size>1541</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjYwMTMzCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggMTI2MmZkYTVlYTZiOGRm
YmE0NDNkMDBiYzg4ZGQxOTVkYzVjMTIyZC4uMTg2OWNkMjIwNjg4N2UzYTZiNjE0MzJlZDk5ZjU4
MzA0NmQ3MmY1ZiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE2IEBACisyMDIwLTA0LTE1ICBDaHJp
cy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