Changeset 239353 in webkit


Ignore:
Timestamp:
Dec 18, 2018 2:03:07 PM (5 years ago)
Author:
rniwa@webkit.org
Message:

Some iOS app crash in FrameLoader::checkCompleted
https://bugs.webkit.org/show_bug.cgi?id=192804
<rdar://problem/44240573>

Reviewed by Tim Horton.

It's possible for the main thread to call into WebCore / UIWebView selectors while Web thread
is trying to send a delegate message. Disable the release assertion while this is happening
so that iOS app would not crash.

Unfortunately no new test as there is no way to easily test UIWebView in iOS,
and this requires a race between the web thread & the main thread.

  • dom/ScriptDisallowedScope.h:

(WebCore::ScriptDisallowedScope::InMainThread::isScriptAllowed):

  • platform/ios/wak/WebCoreThread.h:
  • platform/ios/wak/WebCoreThread.mm:

(WebThreadDelegateMessageScope::WebThreadDelegateMessageScope):
(WebThreadDelegateMessageScope::~WebThreadDelegateMessageScope):
(SendDelegateMessage):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239352 r239353  
     12018-12-18  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Some iOS app crash in FrameLoader::checkCompleted
     4        https://bugs.webkit.org/show_bug.cgi?id=192804
     5        <rdar://problem/44240573>
     6
     7        Reviewed by Tim Horton.
     8
     9        It's possible for the main thread to call into WebCore / UIWebView selectors while Web thread
     10        is trying to send a delegate message. Disable the release assertion while this is happening
     11        so that iOS app would not crash.
     12
     13        Unfortunately no new test as there is no way to easily test UIWebView in iOS,
     14        and this requires a race between the web thread & the main thread.
     15
     16        * dom/ScriptDisallowedScope.h:
     17        (WebCore::ScriptDisallowedScope::InMainThread::isScriptAllowed):
     18        * platform/ios/wak/WebCoreThread.h:
     19        * platform/ios/wak/WebCoreThread.mm:
     20        (WebThreadDelegateMessageScope::WebThreadDelegateMessageScope):
     21        (WebThreadDelegateMessageScope::~WebThreadDelegateMessageScope):
     22        (SendDelegateMessage):
     23
    1242018-12-18  David Kilzer  <ddkilzer@apple.com>
    225
  • trunk/Source/WebCore/dom/ScriptDisallowedScope.h

    r230983 r239353  
    2626#include "ContainerNode.h"
    2727#include <wtf/MainThread.h>
     28
     29#if PLATFORM(IOS_FAMILY)
     30#include "WebCoreThread.h"
     31#endif
    2832
    2933namespace WebCore {
     
    8791        {
    8892            ASSERT(isMainThread());
     93#if PLATFORM(IOS_FAMILY)
     94            return !s_count || webThreadDelegateMessageScopeCount;
     95#else
    8996            return !s_count;
     97#endif
    9098        }
    9199    };
  • trunk/Source/WebCore/platform/ios/wak/WebCoreThread.h

    r226291 r239353  
    4545   
    4646extern volatile bool webThreadShouldYield;
     47extern volatile unsigned webThreadDelegateMessageScopeCount;
    4748
    4849#ifdef __OBJC__
  • trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm

    r237266 r239353  
    133133static NSMutableArray* sAsyncDelegates = nil;
    134134
     135WEBCORE_EXPORT volatile unsigned webThreadDelegateMessageScopeCount = 0;
     136
    135137static inline void SendMessage(NSInvocation* invocation)
    136138{
     
    172174}
    173175
     176class WebThreadDelegateMessageScope {
     177public:
     178    WebThreadDelegateMessageScope() { ++webThreadDelegateMessageScopeCount; }
     179    ~WebThreadDelegateMessageScope()
     180    {
     181        ASSERT(webThreadDelegateMessageScopeCount);
     182        --webThreadDelegateMessageScopeCount;
     183    }
     184};
     185
    174186static void SendDelegateMessage(NSInvocation* invocation)
    175187{
     
    195207
    196208    {
     209        WebThreadDelegateMessageScope delegateScope;
    197210        // Code block created to scope JSC::JSLock::DropAllLocks outside of WebThreadLock()
    198211        JSC::JSLock::DropAllLocks dropAllLocks(WebCore::commonVM());
Note: See TracChangeset for help on using the changeset viewer.