[Webkit-unassigned] [Bug 172983] New: Weird isMainThread() ASSERT on local iOS build

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jun 6 08:31:28 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=172983

            Bug ID: 172983
           Summary: Weird isMainThread() ASSERT on local iOS build
           Product: WebKit
           Version: WebKit Local Build
          Hardware: iPhone / iPad
                OS: iOS 10
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebKit Misc.
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: dev+webkit at mattlilek.com

I recently build ToT WebKit and am trying to run my iOS app against my local build in the iOS simulator. Unfortunately it crashes on launch due to an isMainThread() assert firing, even though this code appears to me to be running on the main thread. Any ideas on whether I'm doing something wrong or if there's a bug here would be greatly appreciated.

* Git clone from webkit.org - r217789
* Xcode 8.3.2 (8E2002) on macOS Sierra 10.12.6 (16G12b)
* Built using "./Tools/Scripts/build-webkit --debug --ios-simulator"

Running my app with "./Tools/Scripts/run-webkit-app --ios-simulator --debug /path/to/My.app" successfully launches the iOS 10.3 simulator, installs my app and then hangs on its splash screen. I'm unable to attach with LLDB, nothing in the console. So I dug into what run-webkit-app does and for iOS, it looks like it just sets the DYLD_FRAMEWORK_PATH and DYLD_LIBRARY_PATH environment variables to my built WebKit. I set those in my app's Xcode scheme and ran from Xcode. On startup, as my app's creating its first WKWebView, it hits the following ASSERT:

ASSERTION FAILED: isMainThread()
/Users/matt/Code/external/WebKit/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp(203) : void WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver(WTF::Function<void (const Vector<String> &, const Vector<String> &, bool)> &&)
1   0x107f2666d WTFCrash
2   0x10e253849 WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver(WTF::Function<void (WTF::Vector<WTF::String, 0ul, WTF::CrashOnOverflow, 16ul> const&, WTF::Vector<WTF::String, 0ul, WTF::CrashOnOverflow, 16ul> const&, bool)>&&)
3   0x10e276f6f WebKit::WebsiteDataStore::registerSharedResourceLoadObserver()
4   0x10e2101ce WebKit::WebProcessPool::platformInitialize()
5   0x10e1d9927 WebKit::WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration&)
[snip - full stack trace below]

Stepping into how the final value of isMainThread is determined, it looks like its calling the USE(WEB_THREAD) version of isMainThread in MainThreadMac.mm. I see:
(lldb) p isWebThread()
(bool) $0 = false
(lldb) p (int)pthread_main_np()
(int) $1 = 1
(lldb) p webThreadIsUninitializedOrLockedOrDisabled()
(bool) $2 = false
(lldb) p WebCoreWebThreadIsLockedOrDisabled
(bool (*)()) $3 = 0x00000001233b4070 (WebCore`::WebThreadIsLockedOrDisabled() at WebCoreThread.mm:947)
(lldb) p WebCoreWebThreadIsLockedOrDisabled()
(bool) $4 = false
(lldb) p WebThreadIsEnabled()
(bool) $6 = true
(lldb) p WebThreadIsLocked()
(bool) $7 = false

I don't remember enough about iOS WebKit to know how crazy some of these values are. Before this, if I set a break point on isMainThread(), I do get a hit from some of UIKit's WebKit initialization, but I thought that all lived peacefully side-by-side? Do I need to build or run this differently somehow?

Full backtrace -
(Note: The AsyncWebView class in here is a simple subclass of WKWebView that just forwards on some delegate methods and has conveniences for calling the various load() methods. It doesn't do anything weird, promise.)
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xbbadbeef)
    frame #0: 0x0000000107f26674 JavaScriptCore`::WTFCrash() at Assertions.cpp:292
  * frame #1: 0x000000010e253849 WebKit`WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver(this=0x000000012fbfa080, shouldPartitionCookiesForDomainsHandler=0x00007fff5faa8280)>&&) at WebResourceLoadStatisticsStore.cpp:203
    frame #2: 0x000000010e276f6f WebKit`WebKit::WebsiteDataStore::registerSharedResourceLoadObserver(this=0x000000012fbe3000) at WebsiteDataStore.cpp:1256
    frame #3: 0x000000010e2101ce WebKit`WebKit::WebProcessPool::platformInitialize(this=0x00007fcf81866e10) at WebProcessPoolCocoa.mm:152
    frame #4: 0x000000010e1d9927 WebKit`WebKit::WebProcessPool::WebProcessPool(this=0x00007fcf81866e10, configuration=0x00006000003c2768) at WebProcessPool.cpp:254
    frame #5: 0x000000010e1d815d WebKit`WebKit::WebProcessPool::WebProcessPool(this=0x00007fcf81866e10, configuration=0x00006000003c2768) at WebProcessPool.cpp:247
    frame #6: 0x000000010e426e72 WebKit`void API::Object::constructInWrapper<WebKit::WebProcessPool, API::ProcessPoolConfiguration&>(wrapper=0x00007fcf81866e00, args=0x00006000003c2768) at APIObject.h:209
    frame #7: 0x000000010e426e07 WebKit`::-[WKProcessPool _initWithConfiguration:](self=0x00007fcf81866e00, _cmd="_initWithConfiguration:", configuration=0x00006000003c2760) at WKProcessPool.mm:78
    frame #8: 0x000000010e426f16 WebKit`::-[WKProcessPool init](self=0x00007fcf81866e00, _cmd="init") at WKProcessPool.mm:85
    frame #9: 0x000000010e49138f WebKit`-[WKWebViewConfiguration processPool]::$_0::operator(this=0x00007fff5faa8c98)() const at WKWebViewConfiguration.mm:339
    frame #10: 0x000000010e48e1c1 WebKit`WKProcessPool* LazyInitialized<WTF::RetainPtr<WKProcessPool> >::get<-[WKWebViewConfiguration processPool]::$_0>(this=0x00006100003c0968, f=0x00007fff5faa8c98) at WKWebViewConfiguration.mm:61
    frame #11: 0x000000010e48e16d WebKit`::-[WKWebViewConfiguration processPool](self=0x00006100003c0960, _cmd="processPool") at WKWebViewConfiguration.mm:339
    frame #12: 0x000000010e48daac WebKit`::-[WKWebViewConfiguration copyWithZone:](self=0x00006100003c0960, _cmd="copyWithZone:", zone=0x0000000000000000) at WKWebViewConfiguration.mm:271
    frame #13: 0x000000010e4560aa WebKit`::-[WKWebView _initializeWithConfiguration:](self=0x00007fcf8186e800, _cmd="_initializeWithConfiguration:", configuration=0x00006100003c0960) at WKWebView.mm:411
    frame #14: 0x000000010e45bda5 WebKit`::-[WKWebView initWithFrame:configuration:](self=0x00007fcf8186e800, _cmd="initWithFrame:configuration:", frame=(origin = (x = 0, y = 0), size = (width = 0, height = 0)), configuration=0x00006100003c0960) at WKWebView.mm:616
    frame #15: 0x000000010060dc97 NYTimes`AsyncWebView.init(frame=(origin = (x = 0, y = 0), size = (width = 0, height = 0)), configuration=0x00006100003c0960, activityIndicatorStyle=article) -> AsyncWebView at AsyncWebView.swift:103
    frame #16: 0x000000010060de13 NYTimes`AsyncWebView.__allocating_init(frame : CGRect, configuration : WKWebViewConfiguration, activityIndicatorStyle : ActivityIndicatorStyle) -> AsyncWebView at AsyncWebView.swift:0
    frame #17: 0x000000010060dec9 NYTimes`static AsyncWebView.asyncWebView(configuration=0x00006100003c0960, userContentController=0x00006100001a9d80, activityIndicatorStyle=article, self=Newsreader.AsyncWebView) -> AsyncWebView at AsyncWebView.swift:115
    frame #18: 0x00000001001d0aa6 NYTimes`ArticleViewController.init(aDecoder=0x00007fcf8505c800) -> ArticleViewController? at ArticleViewController.swift:154
    frame #19: 0x00000001001d0bbd NYTimes`@objc ArticleViewController.init(coder : NSCoder) -> ArticleViewController? at ArticleViewController.swift:0
    frame #20: 0x000000010bb71f54 UIKit`-[UIClassSwapper initWithCoder:] + 246
    frame #21: 0x000000010bd624af UIKit`UINibDecoderDecodeObjectForValue + 693
    frame #22: 0x000000010bd621ef UIKit`-[UINibDecoder decodeObjectForKey:] + 89
    frame #23: 0x000000010bb71c20 UIKit`-[UIRuntimeConnection initWithCoder:] + 178
    frame #24: 0x000000010bd624af UIKit`UINibDecoderDecodeObjectForValue + 693
    frame #25: 0x000000010bd6264d UIKit`UINibDecoderDecodeObjectForValue + 1107
    frame #26: 0x000000010bd621ef UIKit`-[UINibDecoder decodeObjectForKey:] + 89
    frame #27: 0x000000010bb70e1d UIKit`-[UINib instantiateWithOwner:options:] + 1262
    frame #28: 0x000000010bf2982f UIKit`-[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
    frame #29: 0x00000001002bd117 NYTimes`StoryboardSceneType<A where ...>.viewController(self=articleViewControllerScene) -> UIViewController at Generated.Storyboards.swift:29
    frame #30: 0x00000001002be39f NYTimes`static StoryboardScene.Article.instantiateArticleViewController(self=Newsreader.StoryboardScene.Article) -> ArticleViewController at Generated.Storyboards.swift:86
    frame #31: 0x00000001005011e9 NYTimes`static ReusableItemPool.(articleViewControllerPool(resourceProvider : ResourceProvider) -> ReusableItemPool<ArticleViewController>).(closure #1) at ReusableItemPool.swift:105
    frame #32: 0x0000000100501301 NYTimes`static ReusableItemPool.(_0=0, factory=0x00000001005011e0 NYTimes`static Newsreader.ReusableItemPool.(articleViewControllerPool (resourceProvider : NYTFusionContentLayer.ResourceProvider) -> Newsreader.ReusableItemPool<Newsreader.ArticleViewController>).(closure #1) at ReusableItemPool.swift:104, resourceProvider=0x000061000026af80, pool=0x0000610000252b40) -> ReusableItemPool<ArticleViewController>).(closure #2) at ReusableItemPool.swift:113
    frame #33: 0x0000000100500df3 NYTimes`thunk at ReusableItemPool.swift:0
    frame #34: 0x00000001119860f4 libswiftCore.dylib`(extension in Swift):Swift.Sequence.forEach ((A.Iterator.Element) throws -> ()) throws -> () + 404
    frame #35: 0x000000010050118e NYTimes`static ReusableItemPool.articleViewControllerPool(resourceProvider=0x000061000026af80, self=Newsreader.ReusableItemPool<Newsreader.ArticleViewController>) -> ReusableItemPool<ArticleViewController> at ReusableItemPool.swift:118
    frame #36: 0x0000000100396484 NYTimes`RootFlowCoordinator.presentRootInterface(application=0x00007fcf80c03480, launchOptions=nil, self=0x00007fcf80c26320) -> Bool at RootFlowCoordinator.swift:204
    frame #37: 0x000000010019aa37 NYTimes`AppController.application(application=0x00007fcf80c03480, launchOptions=nil, self=0x00007fcf80e007b0) -> Bool at AppController.swift:122
    frame #38: 0x000000010059d255 NYTimes`AppDelegate.application(application=0x00007fcf80c03480, launchOptions=nil, self=0x0000610000220200) -> Bool at AppDelegate.swift:18
    frame #39: 0x000000010059d354 NYTimes`@objc AppDelegate.application(UIApplication, willFinishLaunchingWithOptions : [UIApplicationLaunchOptionsKey : Any]?) -> Bool at AppDelegate.swift:0
    frame #40: 0x000000010b7608e1 UIKit`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 181
    frame #41: 0x000000010b76223c UIKit`-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4119
    frame #42: 0x000000010b768584 UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1709
    frame #43: 0x000000010b765793 UIKit`-[UIApplication workspaceDidEndTransaction:] + 182
    frame #44: 0x0000000113ac05f6 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    frame #45: 0x0000000113ac046d FrontBoardServices`-[FBSSerialQueue _performNext] + 186
    frame #46: 0x0000000113ac07f6 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 45
    frame #47: 0x0000000105286c01 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #48: 0x000000010526c0cf CoreFoundation`__CFRunLoopDoSources0 + 527
    frame #49: 0x000000010526b5ff CoreFoundation`__CFRunLoopRun + 911
    frame #50: 0x000000010526b016 CoreFoundation`CFRunLoopRunSpecific + 406
    frame #51: 0x000000010b76402f UIKit`-[UIApplication _run] + 468
    frame #52: 0x000000010b76a0d4 UIKit`UIApplicationMain + 159
    frame #53: 0x00000001004fe8ff NYTimes`main at main.swift:52
    frame #54: 0x000000011241965d libdyld.dylib`start + 1
    frame #55: 0x000000011241965d libdyld.dylib`start + 1

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170606/ebac6b04/attachment-0001.html>


More information about the webkit-unassigned mailing list