<?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>200599</bug_id>
          
          <creation_ts>2019-08-09 16:25:18 -0700</creation_ts>
          <short_desc>Possible non-thread safe usage of RefCounted in ~VideoFullscreenControllerContext()</short_desc>
          <delta_ts>2019-08-09 17:57: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>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>200507</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>achristensen</cc>
    
    <cc>commit-queue</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>ggaren</cc>
    
    <cc>jer.noble</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1560111</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-09 16:25:18 -0700</bug_when>
    <thetext>Possible non-thread safe usage of RefCounted in ~VideoFullscreenControllerContext():

ASSERTION FAILED: !areThreadingCheckedEnabled() || m_isOwnedByMainThread == isMainThread()
        /Volumes/Data/WebKit/OpenSource/WebKitBuild/Debug-iphonesimulator/usr/local/include/wtf/RefCounted.h(117) : bool WTF::RefCountedBase::derefBase() const
        1   0x1106c60c9 WTFCrash
        2   0x11e5e8dbb WTFCrashWithInfo(int, char const*, char const*, int)
        3   0x11e5fd0be WTF::RefCountedBase::derefBase() const
        4   0x11e6a457f WTF::RefCounted&lt;WebCore::EventListener&gt;::deref() const
        5   0x12248ce25 void WTF::derefIfNotNull&lt;WebCore::PlaybackSessionModelMediaElement&gt;(WebCore::PlaybackSessionModelMediaElement*)
        6   0x12248cde9 WTF::RefPtr&lt;WebCore::PlaybackSessionModelMediaElement, WTF::DumbPtrTraits&lt;WebCore::PlaybackSessionModelMediaElement&gt; &gt;::~RefPtr()
        7   0x12247b215 WTF::RefPtr&lt;WebCore::PlaybackSessionModelMediaElement, WTF::DumbPtrTraits&lt;WebCore::PlaybackSessionModelMediaElement&gt; &gt;::~RefPtr()
        8   0x12247aef5 VideoFullscreenControllerContext::~VideoFullscreenControllerContext()
        9   0x12247b275 VideoFullscreenControllerContext::~VideoFullscreenControllerContext()
        10  0x12247b319 VideoFullscreenControllerContext::~VideoFullscreenControllerContext()
        11  0x12248cd82 WTF::ThreadSafeRefCounted&lt;VideoFullscreenControllerContext, (WTF::DestructionThread)0&gt;::deref() const::&apos;lambda&apos;()::operator()() const
        12  0x12248cd3d WTF::ThreadSafeRefCounted&lt;VideoFullscreenControllerContext, (WTF::DestructionThread)0&gt;::deref() const
        13  0x12248cfc5 void WTF::derefIfNotNull&lt;VideoFullscreenControllerContext&gt;(VideoFullscreenControllerContext*)
        14  0x12248cf89 WTF::RefPtr&lt;VideoFullscreenControllerContext, WTF::DumbPtrTraits&lt;VideoFullscreenControllerContext&gt; &gt;::~RefPtr()
        15  0x12247bbe5 WTF::RefPtr&lt;VideoFullscreenControllerContext, WTF::DumbPtrTraits&lt;VideoFullscreenControllerContext&gt; &gt;::~RefPtr()
        16  0x12248afc5 VideoFullscreenControllerContext::volumeChanged(double)::$_21::~$_21()
        17  0x122480725 VideoFullscreenControllerContext::volumeChanged(double)::$_21::~$_21()
        18  0x122480709 __destroy_helper_block_e8_32c64_ZTSKZN32VideoFullscreenControllerContext13volumeChangedEdE4$_21
        19  0x7fff52a089c2 _Block_release
        20  0x7fff529777f9 _dispatch_client_callout
        21  0x7fff52983d22 _dispatch_main_queue_callback_4CF
        22  0x7fff23b72e19 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
        23  0x7fff23b6da79 __CFRunLoopRun
        24  0x7fff23b6ce36 CFRunLoopRunSpecific
        25  0x7fff2574803f -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
        26  0x10f6575c6 TestWebKitAPI::Util::run(bool*)
        27  0x10f1f4cd4 TestWebKitAPI::WebKitLegacy_AudioSessionCategoryIOS_Test::TestBody()
        28  0x10f794dee void testing::internal::HandleSehExceptionsInMethodIfSupported&lt;testing::Test, void&gt;(testing::Test*, void (testing::Test::*)(), char const*)
        29  0x10f7735eb void testing::internal::HandleExceptionsInMethodIfSupported&lt;testing::Test, void&gt;(testing::Test*, void (testing::Test::*)(), char const*)
        30  0x10f773516 testing::Test::Run()
        31  0x10f774395 testing::TestInfo::Run()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560116</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-09 16:32:36 -0700</bug_when>
    <thetext>Likely the ref&apos;ing of |this| here:
void VideoFullscreenControllerContext::volumeChanged(double volume)
{
    if (WebThreadIsCurrent()) {
        dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), volume] {
            protectedThis-&gt;volumeChanged(volume);
        });
        return;
    }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560117</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-09 16:35:49 -0700</bug_when>
    <thetext>So we end up destroying the VideoFullscreenControllerContext on the UIThread, which is fine. However, this ends up deref&apos;ing a PlaybackSessionModelMediaElement on the UIThread, even though PlaybackSessionModelMediaElement objects are WebThread objects (and we&apos;re not holding the WebThreadLock).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560119</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-09 16:38:15 -0700</bug_when>
    <thetext>This is likely VideoFullscreenControllerContext::m_playbackModel, which is a RefPtr&lt;PlaybackSessionModelMediaElement&gt; and PlaybackSessionModelMediaElement is RefCounted (not ThreadSafeRefCounted).

We could mark it as ThreadSafeRefCounted but I doubt this is the right fix here since we may end up destroying the object on the wrong thread. It is more likely I need to make sure the object gets destroyed on the WebThread, or grab the WebThreadLock.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560124</commentid>
    <comment_count>4</comment_count>
      <attachid>375980</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-09 16:54:30 -0700</bug_when>
    <thetext>Created attachment 375980
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560134</commentid>
    <comment_count>5</comment_count>
      <attachid>375980</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2019-08-09 17:14:38 -0700</bug_when>
    <thetext>Comment on attachment 375980
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560143</commentid>
    <comment_count>6</comment_count>
      <attachid>375980</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-08-09 17:56:37 -0700</bug_when>
    <thetext>Comment on attachment 375980
Patch

Clearing flags on attachment: 375980

Committed r248492: &lt;https://trac.webkit.org/changeset/248492&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560144</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-08-09 17:56:39 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1560145</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-08-09 17:57:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/54150479&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>375980</attachid>
            <date>2019-08-09 16:54:30 -0700</date>
            <delta_ts>2019-08-09 17:56:37 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-200599-20190809165429.patch</filename>
            <type>text/plain</type>
            <size>1991</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjQ4NDgxCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggN2FjYzc1YmY4NTU5NTc1
ZTk2N2M1OGYwYThiNDQ3MTIyMzAxMjY4Ni4uNGQzN2E3YTIzMjkwMjNjYmY5NjE4OTBmODYxNzE2
YzQ1YmI4YWI0ZCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE3IEBACisyMDE5LTA4LTA5ICBDaHJp
cyBEdW1leiAgPGNkdW1lekBhcHBsZS5jb20+CisKKyAgICAgICAgUG9zc2libGUgbm9uLXRocmVh
ZCBzYWZlIHVzYWdlIG9mIFJlZkNvdW50ZWQgaW4gflZpZGVvRnVsbHNjcmVlbkNvbnRyb2xsZXJD
b250ZXh0KCkKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lk
PTIwMDU5OQorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAg
IFdlYlZpZGVvRnVsbHNjcmVlbkNvbnRyb2xsZXJBVktpdC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