我正在使用UIWebView在我的iOS应用中嵌入YouTube HTML播放器,有时当应用从背景进入前景时(视频正在播放),应用程序刚冻结,我得到0x000000008badf00d崩溃。
OS Version: iOS 7.1.1 (11D201)
Report Version: 104
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information:
com.myapp.myapp failed to resume in time
Elapsed total CPU time (seconds): 6.460 (user 6.460, system 0.000), 27% CPU
Elapsed application CPU time (seconds): 3.069, 13% CPU
Thread 0:
0 libsystem_kernel.dylib 0x39911f9c __psynch_mutexwait + 24
1 libsystem_pthread.dylib 0x3997b298 _pthread_mutex_lock_contended + 48
2 libsystem_pthread.dylib 0x39977d36 _pthread_mutex_lock + 258
3 WebCore 0x36e2f190 _WebTryThreadLock(bool) + 40
4 WebCore 0x36e2ffb8 WebThreadLock + 76
5 WebCore 0x36e6b962 -[TileLayer layoutSublayers] + 14
6 QuartzCore 0x3106db3a CA::Layer::layout_if_needed(CA::Transaction*) + 346
7 QuartzCore 0x3106d9cc CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
8 QuartzCore 0x3106d3e0 CA::Context::commit_transaction(CA::Transaction*) + 224
9 QuartzCore 0x3106d1f2 CA::Transaction::commit() + 310
10 AVFoundation 0x2da4fb60 -[AVPlayerLayer _updateSubtitles:forceRender:] + 696
11 AVFoundation 0x2da500a8 -[AVPlayerLayer layerDidBecomeVisible:] + 200
12 QuartzCore 0x3106bbf4 CA::Layer::mark_visible(CA::Transaction*, bool) + 80
13 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
14 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
15 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
16 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
17 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
18 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
19 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
20 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
21 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
22 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
23 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
24 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
25 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
26 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
27 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
28 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
29 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
30 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
31 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
32 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
33 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
34 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
35 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
36 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
37 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
38 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
39 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
40 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
41 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
42 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
43 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
44 QuartzCore 0x3106bc30 CA::Layer::mark_visible(CA::Transaction*, bool) + 140
45 QuartzCore 0x3106cb82 CA::Layer::set_visible(unsigned int) + 346
46 QuartzCore 0x3106c9e6 CA::Context::set_layer(void const*) + 134
47 UIKit 0x313feab2 -[UIWindow _createContext] + 1138
48 UIKit 0x316572a4 _UIWindowUpdateVisibleContextOrder + 172
49 UIKit 0x31657158 +[UIWindow _prepareWindowsPassingTestForAppResume:] + 12
50 UIKit 0x315fc534 -[UIApplication _handleApplicationResumeEvent:] + 72
51 UIKit 0x313fb60e -[UIApplication handleEvent:withNewEvent:] + 1878
52 UIKit 0x313fadf4 -[UIApplication sendEvent:] + 68
53 UIKit 0x3145f400 _UIApplicationHandleEvent + 612
54 GraphicsServices 0x33a68b52 _PurpleEventCallback + 606
55 GraphicsServices 0x33a6873a PurpleEventCallback + 30
56 CoreFoundation 0x2eb91844 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
57 CoreFoundation 0x2eb917de __CFRunLoopDoSource1 + 342
58 CoreFoundation 0x2eb8ffaa __CFRunLoopRun + 1402
59 CoreFoundation 0x2eafa764 CFRunLoopRunSpecific + 520
60 CoreFoundation 0x2eafa546 CFRunLoopRunInMode + 102
61 GraphicsServices 0x33a676ce GSEventRunModal + 134
62 UIKit 0x3145988c UIApplicationMain + 1132
63 myapp 0x0003ba0e main (main.m:14)
64 myapp 0x0003b9c4 start + 36
基本上我使用UIWebView
加载带有YouTube HTML播放器的HTML文件,并使用[webView stringByEvaluatingJavaScriptFromString: jsString]
来控制它(例如loadVideoById()
,play()
,{{1}等)。还有一些机制,所以应用程序可以在后台播放视频,大多数时候它运行良好,这种崩溃只发生在它在后台播放几个视频,并试图进入前景,但很难再现。
似乎webthread正在锁定主线程,所以iOS杀了我的应用程序,我已经研究了几个星期这个问题,但没有运气,任何建议都欢迎。
答案 0 :(得分:0)
经过大量实验后,当app进入后台时,可以通过隐藏带有CSS的html播放器div标签来避免此问题,然后再次显示 AFTER 收到 appDidBecomeActive 事件。
我认为YouTube html播放器正试图在应用变为活动状态时执行与UI相关的操作,因此可能会锁定主线程并导致0x000000008badf00d崩溃。
希望这个答案可以帮助别人。
答案 1 :(得分:0)
我在iOS 7上遇到过这个问题,只是在尝试使用包含后台线程上的YouTube iFrame播放器的HTML字符串调用loadHTMLString:baseURL:
时。使用我所有其他UI调用将该调用移动到主线程似乎解决了这个问题。
我应该注意到我无法使用iOS 8和9重新创建此问题,因此这可能是一个WebKit错误,该错误已通过以后的iOS更新修复。