<?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>172390</bug_id>
          
          <creation_ts>2017-05-19 15:06:39 -0700</creation_ts>
          <short_desc>[iOS]: RunLoop::main().dispatch() needs to take into account USE_WEB_THREAD</short_desc>
          <delta_ts>2024-07-30 11:12:04 -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>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=277299</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aestes</cc>
    
    <cc>andersca</cc>
    
    <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>ggaren</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1310793</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2017-05-19 15:06:39 -0700</bug_when>
    <thetext>[iOS]: RunLoop::main().dispatch() needs to take into account WEB_THREAD

There are cases of RunLoop::main().dispatch() in WebCore that may not be safe if USE_WEB_THREAD

    bindings/js/SerializedScriptValue.cpp
    3166:    RunLoop::main().dispatch([this, conditionPtr = &amp;condition, valuePtr = &amp;value] {

    Modules/applepay/ApplePaySession.cpp
    640:        RunLoop::main().dispatch([promise, canMakePayments]() mutable {

    workers/WorkerMessagingProxy.cpp
    168:    RunLoop::main().dispatch([this, protectedThis = makeRef(*this), message = message.isolatedCopy()] {

If possible callOnMainThread could be used or WebThreadRun. See Modules/websockets/WebSocket.cpp&apos;s approach.

Note: WorkerMessagingProxy case, callOnMainThread couldn&apos;t be used and was specifically avoided.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1310885</commentid>
    <comment_count>1</comment_count>
    <who name="Andy Estes">aestes</who>
    <bug_when>2017-05-19 17:22:25 -0700</bug_when>
    <thetext>(In reply to Joseph Pecoraro from comment #0)
&gt;     Modules/applepay/ApplePaySession.cpp
&gt;     640:        RunLoop::main().dispatch([promise, canMakePayments]()
&gt; mutable {
&gt; 

In practice this is safe because Apple Pay is disabled at runtime in WebKit1 clients, so this code won&apos;t execute on a WebThread.

I think callOnMainThread() could be used here without a problem, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1310906</commentid>
    <comment_count>2</comment_count>
    <who name="Anders Carlsson">andersca</who>
    <bug_when>2017-05-19 18:01:58 -0700</bug_when>
    <thetext>RunLoop::main().dispatch() shouldn&apos;t be web thread aware since it&apos;s used in the UI process. If anything, callOnMainThread should be used in WebCore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1310913</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2017-05-19 18:19:57 -0700</bug_when>
    <thetext>The call to RunLoop::main().dispatch() in SerializedScriptValue.cpp for IndexedDB does look unsafe and should probably be replaced with callOnMainThread().</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>