什么是 FNFPlayer?它从后台线程访问 UIApplication applicationState

Posted

技术标签:

【中文标题】什么是 FNFPlayer?它从后台线程访问 UIApplication applicationState【英文标题】:What is FNFPlayer? It accesses UIApplication applicationState from background thread 【发布时间】:2017-11-28 21:46:04 【问题描述】:

我在 ios 11 (xcode 9) 上经常收到这些警告:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 988, TID: 338692, Thread name: fnf player thread, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4   hairzapp                            0x0000000103a35634 -[FNFPlayerLayer _preventPlayback] + 60
5   hairzapp                            0x0000000103a33f30 -[FNFPlayerLayer _resetGLContext] + 36
6   hairzapp                            0x0000000103a129cc __35-[FNFRenderingThread dispatchSync:]_block_invoke + 28
7   hairzapp                            0x0000000103a128a8 __35-[FNFRenderingThread performBlock:]_block_invoke + 36
8   CoreFoundation                      0x00000001848fa0fc <redacted> + 20
9   CoreFoundation                      0x00000001848f99cc <redacted> + 288
10  CoreFoundation                      0x00000001848f7c34 <redacted> + 2436
11  CoreFoundation                      0x0000000184817fb8 CFRunLoopRunSpecific + 436
12  CoreFoundation                      0x0000000184867098 CFRunLoopRun + 116
13  hairzapp                            0x0000000103a12ba4 -[FNFRenderingThread main] + 204
14  Foundation                          0x0000000185342860 <redacted> + 996
15  libsystem_pthread.dylib             0x000000018457c31c <redacted> + 308
16  libsystem_pthread.dylib             0x000000018457c1e8 <redacted> + 0
17  libsystem_pthread.dylib             0x000000018457ac28 thread_start + 4
2017-11-28 22:33:33.895582+0100 hairzapp[988:338692] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 988, TID: 338692, Thread name: fnf player thread, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4   hairzapp                            0x0000000103a35634 -[FNFPlayerLayer _preventPlayback] + 60
5   hairzapp                            0x0000000103a33f30 -[FNFPlayerLayer _resetGLContext] + 36
6   hairzapp                            0x0000000103a129cc __35-[FNFRenderingThread dispatchSync:]_block_invoke + 28
7   hairzapp                            0x0000000103a128a8 __35-[FNFRenderingThread performBlock:]_block_invoke + 36
8   CoreFoundation                      0x00000001848fa0fc <redacted> + 20
9   CoreFoundation                      0x00000001848f99cc <redacted> + 288
10  CoreFoundation                      0x00000001848f7c34 <redacted> + 2436
11  CoreFoundation                      0x0000000184817fb8 CFRunLoopRunSpecific + 436
12  CoreFoundation                      0x0000000184867098 CFRunLoopRun + 116
13  hairzapp                            0x0000000103a12ba4 -[FNFRenderingThread main] + 204
14  Foundation                          0x0000000185342860 <redacted> + 996
15  libsystem_pthread.dylib             0x000000018457c31c <redacted> + 308
16  libsystem_pthread.dylib             0x000000018457c1e8 <redacted> + 0
17  libsystem_pthread.dylib             0x000000018457ac28 thread_start + 4

你能帮我找到来源吗?我想它一定是我使用的库之一,因为在我的代码中只有很少的对[UIApplication applicationState] 的调用:

pod 'objective-zip', '1.0.3'
pod 'Google-Mobile-Ads-SDK'
pod 'AppLovinSDK'
pod 'AdColony'
pod 'GoogleMobileAdsMediationAppLovin'
pod 'GoogleMobileAdsMediationAdColony'
pod 'GoogleAnalytics'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'FBAudienceNetwork', '4.25.0'
pod 'GoogleConversionTracking'
pod 'Fabric'
pod 'Crashlytics'
pod 'AFNetworking'
pod 'AFNetworkActivityLogger', :git => 'https://github.com/AFNetworking/AFNetworkActivityLogger.git', :branch => '3_0_0'
pod 'iRate'
pod 'Firebase/Core'
pod 'Firebase/Messaging' 
pod 'MBProgressHUD'
pod 'Realm'
pod 'UICollectionViewLeftAlignedLayout'
pod 'OpenCV'
pod 'SCLAlertView-Objective-C'
pod 'CMPopTipView'

如果有人能给我提示如何找到错误的库,我会很高兴。

【问题讨论】:

【参考方案1】:

我猜它有 Facebook SDK 根。 在GitHub 上找到Instagramm class-dump,看起来像一些私人课程。 https://github.com/RishabSwift/InstagramHeaders/blob/master/FNFPlayerLayer.h

- (_Bool)_preventPlayback;    

还在这里找到FNFPlayerLayer“面包屑”:https://github.com/facebook/infer/blob/master/infer/tests/codetoanalyze/objc/ioslints/unavailable_property_ios.m

可能来自FBAudienceNetwork框架,您可以尝试将其从Podfile中删除,然后制作pod install并再次分析控制台日志。

【讨论】:

啊哈!非常感谢!!!但奇怪的是没有其他人有这种行为...... 好的,我更新到 FBAudienceNetwork 4.26.1,错误似乎消失了。谢谢@evgeny-karkan!可以接受答案。

以上是关于什么是 FNFPlayer?它从后台线程访问 UIApplication applicationState的主要内容,如果未能解决你的问题,请参考以下文章

Android中UI线程与后台线程交互设计的6种方法

转载Android中UI线程与后台线程交互设计的5种方法

UWP 在非UI线程中更新UI

从后台线程更新 UI 是一种不好的做法,为啥? [关闭]

通过AsyncTask访问后台后得到的返回数据在Android端显示

找出从后台线程访问的 winforms 控件