<?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>227607</bug_id>
          
          <creation_ts>2021-07-01 20:10:52 -0700</creation_ts>
          <short_desc>WebPageProxy::setAppHighlightsVisibility might send message from a background thread, ASSERTing</short_desc>
          <delta_ts>2021-07-02 10:57:21 -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>WebKit Misc.</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brady Eidson">beidson</reporter>
          <assigned_to name="Brady Eidson">beidson</assigned_to>
          <cc>achristensen</cc>
    
    <cc>cdumez</cc>
    
    <cc>darin</cc>
    
    <cc>ggaren</cc>
    
    <cc>thorton</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1774347</commentid>
    <comment_count>0</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2021-07-01 20:10:52 -0700</bug_when>
    <thetext>WebPageProxy::setAppHighlightsVisibility might send message from a background thread, ASSERTing

&lt;rdar://80056481&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774349</commentid>
    <comment_count>1</comment_count>
      <attachid>432765</attachid>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2021-07-01 20:13:58 -0700</bug_when>
    <thetext>Created attachment 432765
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774355</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2021-07-01 21:19:50 -0700</bug_when>
    <thetext>Can’t we just send the radar to the client? I worry about us opening the door to clients calling ours APIs on non main threads.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774356</commentid>
    <comment_count>3</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2021-07-01 21:25:28 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #2)
&gt; Can’t we just send the radar to the client? I worry about us opening the
&gt; door to clients calling ours APIs on non main threads.

The client is *US*</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774357</commentid>
    <comment_count>4</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2021-07-01 21:27:58 -0700</bug_when>
    <thetext>(In reply to Brady Eidson from comment #3)
&gt; (In reply to Chris Dumez from comment #2)
&gt; &gt; Can’t we just send the radar to the client? I worry about us opening the
&gt; &gt; door to clients calling ours APIs on non main threads.
&gt; 
&gt; The client is *US*

(It&apos;s not really us, but it&apos;s our own block we&apos;re passing to another system framework and it&apos;s expected that block gets called on a non-main thread)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774358</commentid>
    <comment_count>5</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2021-07-01 21:28:17 -0700</bug_when>
    <thetext>(In reply to Brady Eidson from comment #4)
&gt; (In reply to Brady Eidson from comment #3)
&gt; &gt; (In reply to Chris Dumez from comment #2)
&gt; &gt; &gt; Can’t we just send the radar to the client? I worry about us opening the
&gt; &gt; &gt; door to clients calling ours APIs on non main threads.
&gt; &gt; 
&gt; &gt; The client is *US*
&gt; 
&gt; (It&apos;s not really us, but it&apos;s our own block we&apos;re passing to another system
&gt; framework and it&apos;s expected that block gets called on a non-main thread)

So, if you prefer, I could fix this inside that block instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774359</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2021-07-01 21:47:09 -0700</bug_when>
    <thetext>(In reply to Brady Eidson from comment #5)
&gt; (In reply to Brady Eidson from comment #4)
&gt; &gt; (In reply to Brady Eidson from comment #3)
&gt; &gt; &gt; (In reply to Chris Dumez from comment #2)
&gt; &gt; &gt; &gt; Can’t we just send the radar to the client? I worry about us opening the
&gt; &gt; &gt; &gt; door to clients calling ours APIs on non main threads.
&gt; &gt; &gt; 
&gt; &gt; &gt; The client is *US*
&gt; &gt; 
&gt; &gt; (It&apos;s not really us, but it&apos;s our own block we&apos;re passing to another system
&gt; &gt; framework and it&apos;s expected that block gets called on a non-main thread)
&gt; 
&gt; So, if you prefer, I could fix this inside that block instead.

Oh, I see. Then yes, I think it would look nicer to fix it at the call site rather than doing a trampoline in WebPageProxy.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774360</commentid>
    <comment_count>7</comment_count>
      <attachid>432765</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2021-07-01 22:06:21 -0700</bug_when>
    <thetext>Comment on attachment 432765
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=432765&amp;action=review

&gt; Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:591
&gt; +        callOnMainRunLoop([protectedThis = makeRef(*this), appHighlightsVisibility] {

As I mentioned earlier, I think this should be fixed at the call site.

Also, I looked at the call site in WebPageProxy::setUpHighlightsObserver() and I am not convinced this is safe. What ensures that setAppHighlightsVisibility() is not getting called on the background thread while the WebPageProxy is in the middle of destruction on the main thread?
Your call to makeRef(*this) here would try to ref the page even though its destructor is running. Is there something I missed that makes sure this cannot happen?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774363</commentid>
    <comment_count>8</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2021-07-01 22:45:04 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #7)
&gt; Comment on attachment 432765 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=432765&amp;action=review
&gt; 
&gt; &gt; Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:591
&gt; &gt; +        callOnMainRunLoop([protectedThis = makeRef(*this), appHighlightsVisibility] {
&gt; 
&gt; As I mentioned earlier, I think this should be fixed at the call site.

I said the same to Brady elsewhere and he promised to make that change (and then I r+’d anyway :| )</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774488</commentid>
    <comment_count>9</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2021-07-02 09:13:30 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #7)
&gt; Comment on attachment 432765 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=432765&amp;action=review
&gt; 
&gt; &gt; Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:591
&gt; &gt; +        callOnMainRunLoop([protectedThis = makeRef(*this), appHighlightsVisibility] {
&gt; 
&gt; As I mentioned earlier, I think this should be fixed at the call site.
&gt; 
&gt; Also, I looked at the call site in WebPageProxy::setUpHighlightsObserver()
&gt; and I am not convinced this is safe. What ensures that
&gt; setAppHighlightsVisibility() is not getting called on the background thread
&gt; while the WebPageProxy is in the middle of destruction on the main thread?
&gt; Your call to makeRef(*this) here would try to ref the page even though its
&gt; destructor is running. Is there something I missed that makes sure this
&gt; cannot happen?

Right.

Turns out this code is already thread unsafe.

Fixing now with some weakptr and Function&lt;&gt;-foo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774490</commentid>
    <comment_count>10</comment_count>
      <attachid>432803</attachid>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2021-07-02 09:26:14 -0700</bug_when>
    <thetext>Created attachment 432803
Patch reviewed on Slack</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774503</commentid>
    <comment_count>11</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2021-07-02 10:57:19 -0700</bug_when>
    <thetext>Committed r279509 (239361@main): &lt;https://commits.webkit.org/239361@main&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 432803.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>432765</attachid>
            <date>2021-07-01 20:13:58 -0700</date>
            <delta_ts>2021-07-01 21:55:39 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-227607-20210701201358.patch</filename>
            <type>text/plain</type>
            <size>1675</size>
            <attacher name="Brady Eidson">beidson</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjc5NDY3CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IDM2YjhlODY0YjJjNzViNTU2
MGZiZDQ4ZjljOGFjOTZjNzgzNGRkMTUuLjkyMGYzZDgwNGExNWVmMDdiOThhNDViNmNiZDc2NWM3
ZDg2MWE4Y2MgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTMgQEAKKzIwMjEtMDctMDEgIEJyYWR5IEVp
ZHNvbiAgPGJlaWRzb25AYXBwbGUuY29tPgorCisgICAgICAgIFdlYlBhZ2VQcm94eTo6c2V0QXBw
SGlnaGxpZ2h0c1Zpc2liaWxpdHkgbWlnaHQgc2VuZCBtZXNzYWdlIGZyb20gYSBiYWNrZ3JvdW5k
IHRocmVhZCwgQVNTRVJUaW5nCisgICAgICAgIDxyZGFyOi8vODAwNTY0ODE+IGFuZCBodHRwczov
L2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MjI3NjA3CisKKyAgICAgICAgUmV2aWV3
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aWdodHNWaXNp
YmlsaXR5KFdlYkNvcmU6OkhpZ2hsaWdodFZpc2liaWxpdHkgYXBwSGlnaGxpZ2h0c1Zpc2liaWxp
dHkpCiB7CisgICAgaWYgKCFpc01haW5SdW5Mb29wKCkpIHsKKyAgICAgICAgY2FsbE9uTWFpblJ1
bkxvb3AoW3Byb3RlY3RlZFRoaXMgPSBtYWtlUmVmKCp0aGlzKSwgYXBwSGlnaGxpZ2h0c1Zpc2li
aWxpdHldIHsKKyAgICAgICAgICAgIHByb3RlY3RlZFRoaXMtPnNldEFwcEhpZ2hsaWdodHNWaXNp
YmlsaXR5KGFwcEhpZ2hsaWdodHNWaXNpYmlsaXR5KTsKKyAgICAgICAgfSk7CisgICAgICAgIAor
ICAgICAgICByZXR1cm47CisgICAgfQorICAgIAogICAgIGlmICghaGFzUnVubmluZ1Byb2Nlc3Mo
KSkKICAgICAgICAgcmV0dXJuOwogCg==
</data>
<flag name="review"
          id="454820"
          type_id="1"
          status="+"
          setter="thorton"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>432803</attachid>
            <date>2021-07-02 09:26:14 -0700</date>
            <delta_ts>2021-07-02 10:57:20 -0700</delta_ts>
            <desc>Patch reviewed on Slack</desc>
            <filename>pat</filename>
            <type>text/plain</type>
            <size>2185</size>
            <attacher name="Brady Eidson">beidson</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nIGIvU291cmNlL1dlYktpdC9DaGFu
Z2VMb2cKaW5kZXggMzZiOGU4NjRiMmM3Li44OTE0NWQ0MTBhOWEgMTAwNjQ0Ci0tLSBhL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMg
KzEsMTUgQEAKKzIwMjEtMDctMDIgIEJyYWR5IEVpZHNvbiAgPGJlaWRzb25AYXBwbGUu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