【发布时间】:2014-08-28 23:39:52
【问题描述】:
我正在使用 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()、pause() 等)。还有一些机制让应用可以在后台播放视频,大多数情况下它运行良好,这个崩溃只是在它在后台播放了几个视频后才发生,并试图进入前台,但很难重现。
似乎 webthread 正在锁定主线程,所以 iOS 杀死了我的应用程序,我已经研究了这个问题几个星期,但没有运气,欢迎任何建议。
【问题讨论】:
-
可以添加html吗?您在本机上运行的任何线程?
-
请提供更多代码 - 以及用于生成事件的代码。
-
我使用他们的iOS player helper 成功地将 youtube 视频嵌入到 iOS 应用程序中。您将在Google Developer 中找到更多文档。如果您使用它,请注意您不能在应用程序中同时播放多个实例。因此,请确保在 viewDidDissapear 或其他类似方法中强制停止/暂停播放,以防您希望在多个视图控制器中拥有一个播放器
-
@MariusConstantinescu:我已经成功地在我的应用程序中嵌入了 youTube HTML 播放器,而且它在大多数情况下都能正常工作,这种崩溃很难重现。我很确定他们是唯一的 UIWebView 实例将在我的应用程序中嵌入 HTML 播放器,感谢您的建议 =)
-
@trick14: 我没有专门在任何线程中调度,但我使用 javascript 来控制我的 YouTube HTML 播放器,我应该在主线程或任何线程中调用 [webView stringByEvaluatingJavaScriptFromString:jsString] 吗?跨度>
标签: ios objective-c multithreading uiwebview youtube-api