- 加载UIWebView时,未在主线程上调用[MPVolumeView initWithFrame:style]

时间:2014-09-21 20:08:51

标签: ios objective-c uiwebview

我在UIWebView中遇到了一个奇怪的崩溃,不知何故,MPVolumeView以某种方式被OS实例化,而不是在主线程中。结果,应用程序崩溃。

我的代码中没有任何地方MPVolumeView被使用或调用,所以我不确定我应该在这做什么。崩溃在iOS 7中不存在,并且仅在iOS 8中出现。

这是在崩溃前的追溯:

Stacktrace: (
    0   CustomFramework                    0x000000010e918587 PSPDFAssertIfNotMainThread + 87
    1   CustomFramework                    0x000000010e918690 __PSPDFUIKitMainThreadGuard_block_invoke_2 + 32
    2   UIKit                               0x000000010cd2338c -[UIView initWithFrame:] + 153
    3   MediaPlayer                         0x0000000119b64b0d -[MPVolumeView initWithFrame:style:] + 80
    4   UIKit                               0x000000010cd22fb7 -[UIView init] + 62
    5   WebCore                             0x00000001151f9913 -[WebMediaSessionHelper initWithCallback:] + 115
    6   WebCore                             0x00000001151f9259 _ZN7WebCore22MediaSessionManageriOSC2Ev + 89
    7   WebCore                             0x00000001151f91d1 _ZN7WebCore19MediaSessionManager13sharedManagerEv + 49
    8   WebCore                             0x00000001151f7b6e _ZN7WebCore12MediaSessionC2ERNS_18MediaSessionClientE + 46
    9   WebCore                             0x0000000114be08a8 _ZN7WebCore16HTMLMediaSession6createERNS_18MediaSessionClientE + 40
    10  WebCore                             0x0000000114bc3545 _ZN7WebCore16HTMLMediaElementC2ERKNS_13QualifiedNameERNS_8DocumentEb + 1733
    11  WebCore                             0x0000000114c36118 _ZN7WebCore16HTMLVideoElementC2ERKNS_13QualifiedNameERNS_8DocumentEb + 24
    12  WebCore                             0x0000000114c34219 _ZN7WebCore16HTMLVideoElement6createERKNS_13QualifiedNameERNS_8DocumentEb + 57
    13  WebCore                             0x0000000114b9ef41 _ZN7WebCoreL16videoConstructorERKNS_13QualifiedNameERNS_8DocumentEPNS_15HTMLFormElementEb + 81
    14  WebCore                             0x0000000114b9df14 _ZN7WebCore18HTMLElementFactory13createElementERKNS_13QualifiedNameERNS_8DocumentEPNS_15HTMLFormElementEb + 356
    15  WebCore                             0x0000000114b8af85 _ZN7WebCore12HTMLDocument13createElementERKN3WTF12AtomicStringERi + 101
    16  WebCore                             0x0000000114e14f35 _ZN7WebCore40jsDocumentPrototypeFunctionCreateElementEPN3JSC9ExecStateE + 357
    17  ???                                 0x0000042139137034 0x0 + 4540738007092
    18  JavaScriptCore                      0x0000000117742d8e llint_entry + 22744
    19  JavaScriptCore                      0x000000011773d291 callToJavaScript + 311
    20  JavaScriptCore                      0x0000000117621be3 _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 35
    21  JavaScriptCore                      0x0000000117603c93 _ZN3JSC11Interpreter7executeEPNS_17ProgramExecutableEPNS_9ExecStateEPNS_8JSObjectE + 8035
    22  JavaScriptCore                      0x000000011747272c _ZN3JSC8evaluateEPNS_9ExecStateERKNS_10SourceCodeENS_7JSValueEPS5_ + 508
    23  WebCore                             0x000000011546d2f4 _ZN7WebCore16ScriptController15evaluateInWorldERKNS_16ScriptSourceCodeERNS_15DOMWrapperWorldE + 260
    24  WebCore                             0x000000011546d609 _ZN7WebCore16ScriptController8evaluateERKNS_16ScriptSourceCodeE + 41
    25  WebCore                             0x0000000115473d62 _ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE + 194
    26  WebCore                             0x0000000114bf6107 _ZN7WebCore16HTMLScriptRunner36executePendingScriptAndDispatchEventERNS_13PendingScriptE + 231
    27  WebCore                             0x0000000114bf68a7 _ZN7WebCore16HTMLScriptRunner29executeParsingBlockingScriptsEv + 135
    28  WebCore                             0x0000000114b8e3fb _ZN7WebCore18HTMLDocumentParser14notifyFinishedEPNS_14CachedResourceE + 59
    29  WebCore                             0x000000011477f067 _ZN7WebCore14CachedResource11checkNotifyEv + 343
    30  WebCore                             0x0000000115553347 _ZN7WebCore17SubresourceLoader16didFinishLoadingEd + 119
    31  CFNetwork                           0x0000000110e205f7 ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 107
    32  CFNetwork                           0x0000000110eec871 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 273
    33  CFNetwork                           0x0000000110e0bb36 _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 72
    34  CoreFoundation                      0x000000010eebe714 CFArrayApplyFunction + 68
    35  CFNetwork                           0x0000000110e0b9f7 _ZN19RunloopBlockContext7performEv + 133
    36  CFNetwork                           0x0000000110e0b836 _ZN17MultiplexerSource7performEv + 256
    37  CFNetwork                           0x0000000110e0b64c _ZN17MultiplexerSource8_performEPv + 72
    38  CoreFoundation                      0x000000010eeebad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    39  CoreFoundation                      0x000000010eee199d __CFRunLoopDoSources0 + 269
    40  CoreFoundation                      0x000000010eee0fd4 __CFRunLoopRun + 868
    41  CoreFoundation                      0x000000010eee0a06 CFRunLoopRunSpecific + 470
    42  WebCore                             0x00000001156e8a95 _ZL12RunWebThreadPv + 469
    43  libsystem_pthread.dylib             0x000000010f842899 _pthread_body + 138
    44  libsystem_pthread.dylib             0x000000010f84272a _pthread_struct_init + 0
    45  libsystem_pthread.dylib             0x000000010f846fc9 thread_start + 13

1 个答案:

答案 0 :(得分:-1)

你有一个框架,以确保"在后台线程上没有调用UIKit方法。但是,如您所见,不建议在生产环境中使用此类框架,仅在调试环境中使用。

这是一个Apple框架错误。据报道,您也应该创建一个错误报告。

确保将助手框架更新为最新版本: https://gist.github.com/steipete/5664345

我的建议是用#if DEBUG语句围绕这个框架。这不应该在生产代码上运行。即使是框架的作者也这么说:

  

您应该只在调试版本中使用它。它不使用私人   API,但我不会发货。