聲明:本文轉載自:獅兄
大致報錯有以下兩點。
1、Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit
2、Main Thread Checker: UI API called on a background thread: -[UIView subviews]
其中Weex庫文件中,有兩行報錯。其中一行如下:
if (!(instance.rootView.subviews) || instance.rootView.subviews.count <=0) {
Xcode中,終端打印報錯信息如下
Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100717b54 +[WXBridgeContext checkEmptyScreen:] + 200
5? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920
6? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96e178 + 28
7? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96d90c + 156
8? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316
9? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240
10? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764
11? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144
12? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372
13? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180
14? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846fa0ec + 340
15? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c57404 + 24
16? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c56c2c + 276
17? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c5479c + 1204
18? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183b74da8 CFRunLoopRunSpecific + 552
19? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001845e9674 + 304
20? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344
21? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846f9efc + 1040
22? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5220 + 272
23? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5110 + 0
24? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d3b10 thread_start + 4
2018-11-13 10:27:06.709273+0800 SinaZC[998:202842] [reports] Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100717b54 +[WXBridgeContext checkEmptyScreen:] + 200
5? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920
6? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96e178 + 28
7? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96d90c + 156
8? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316
9? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240
10? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764
11? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144
12? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372
13? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180
14? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846fa0ec + 340
15? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c57404 + 24
16? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c56c2c + 276
17? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c5479c + 1204
18? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183b74da8 CFRunLoopRunSpecific + 552
19? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001845e9674 + 304
20? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344
21? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846f9efc + 1040
22? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5220 + 272
23? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5110 + 0
24? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d3b10 thread_start + 4
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView subviews]
PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100717bd8 +[WXBridgeContext checkEmptyScreen:] + 332
5? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920
6? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96e178 + 28
7? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96d90c + 156
8? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316
9? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240
10? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764
11? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144
12? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372
13? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180
14? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846fa0ec + 340
15? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c57404 + 24
16? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c56c2c + 276
17? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c5479c + 1204
18? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183b74da8 CFRunLoopRunSpecific + 552
19? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001845e9674 + 304
20? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344
21? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846f9efc + 1040
22? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5220 + 272
23? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5110 + 0
24? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d3b10 thread_start + 4
2018-11-13 10:27:07.068187+0800 SinaZC[998:202842] [reports] Main Thread Checker: UI API called on a background thread: -[UIView subviews]
PID: 998, TID: 202842, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100717bd8 +[WXBridgeContext checkEmptyScreen:] + 332
5? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100716a54 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 2920
6? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96e178 + 28
7? JavaScriptCore? ? ? ? ? ? ? ? ? ? ? 0x000000018a96d90c + 156
8? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007cfe24 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 316
9? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100710cfc __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3240
10? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100713624 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 764
11? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x000000010070fbc0 -[WXBridgeContext createInstance:template:options:data:] + 4144
12? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001007191d0 __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 372
13? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718a0c +[WXBridgeManager _performBlockOnBridgeThread:] + 180
14? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846fa0ec + 340
15? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c57404 + 24
16? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c56c2c + 276
17? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183c5479c + 1204
18? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000183b74da8 CFRunLoopRunSpecific + 552
19? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001845e9674 + 304
20? SinaZC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000100718534 -[WXBridgeManager _runLoopThread] + 344
21? Foundation? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001846f9efc + 1040
22? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5220 + 272
23? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d5110 + 0
24? libsystem_pthread.dylib? ? ? ? ? ? 0x00000001838d3b10 thread_start + 4
2018-11-13 10:27:07.178241+0800 SinaZC[998:202842] <Weex>[error]WXMonitor.m:294, [WX_KEY_EXCEPTION_WXBRIDGE] [file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:895:25] ReferenceError: Can't find variable: process
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:895:25
__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:12052:31
__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:407:36
__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:9725:33
__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:9262:38
__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:9550:32
__webpack_require__@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:22:34
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:68:37
global code@file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234:69:12
file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js?random=1715125234
instanceId:0
options:{
? ? bundleType = Vue;
? ? bundleUrl = "file:///var/containers/Bundle/Application/0A0708CB-4F5C-4029-90B9-F2E562643F66/SinaZC.app/bundlejs/views/home.js";
? ? debug = 1;
? ? env =? ? {
? ? ? ? appName = "\U65b0\U6d6a\U4f17\U6d4b";
? ? ? ? appVersion = "1.8.3";
? ? ? ? deviceHeight = 2436;
? ? ? ? deviceModel = "iPhone10,3";
? ? ? ? deviceWidth = 1125;
? ? ? ? logLevel = log;
? ? ? ? osName = iOS;
? ? ? ? osVersion = "11.4.1";
? ? ? ? platform = iOS;
? ? ? ? scale = 3;
? ? ? ? weexVersion = "0.19.0";
? ? };
}
data:(null)
(
? ? service,
? ? clearTimeout,
? ? setInterval,
? ? clearInterval,
? ? services,
? ? BroadcastChannel,
? ? weex,
? ? setTimeout,
? ? Vue,
? ? getJSFMVersion,
? ? "__WEEX_CALL_JAVASCRIPT__"
)
現象:
iOS項目在手機端運行,直接白屏。
問題查找:
步驟一:
在Weex項目中,執行weex run ios指令時候,終端中打印出如下信息:
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.6.0.beta.2
Analyzing dependencies
Downloading dependencies
Using AMapFoundation (1.5.5)
Using AMapLocation (2.6.1)
Using SDWebImage (3.7.5)
Using SocketRocket (0.4.2)
Using WeexPluginLoader (0.0.1.9.1)
Installing WeexSDK 0.19.0 (was 0.18.0.3)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.
? Choose one of the following devices (Use arrow keys)
步驟二:
檢查Xcode中Podfile 文件。如下:
source 'git@github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
#inhibit_all_warnings!
def common
pod 'WeexSDK',
? ? pod 'WeexPluginLoader'
? ? pod 'SDWebImage', '3.7.5'
? ? pod 'SocketRocket', '0.4.2'
? ? pod 'AMapLocation' #定位SDK
end
target 'WeexDemo' do
? ? common
end
target 'WeexUITestDemo' do
? ? common
end
發現,WeexSDK,并沒有指定版本,但是在Weex項目編譯過程中,出現過Installing WeexSDK 0.19.0 (was 0.18.0.3),說明,這里直接將老的0.18.0.3版本升級到了0.19.0版本。
步驟三:
修改Xcode的Podfile文件,指定WeexSDK版本為0.18.0.3版本
修改后的Podfile文件如下:
source 'git@github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
#inhibit_all_warnings!
def common
pod 'WeexSDK', '0.18.0.3'
? ? pod 'WeexPluginLoader'
? ? pod 'SDWebImage', '3.7.5'
? ? pod 'SocketRocket', '0.4.2'
? ? pod 'AMapLocation' #定位SDK
end
target 'WeexDemo' do
? ? common
end
target 'WeexUITestDemo' do
? ? common
end
步驟四:
進入到Xcode項目根目錄:
在終端中,輸入指令pod install ,更新cocoapods相關庫。
終端信息如下:
ShiXiongweideMacBook-Pro:ios shixiongwei$ pwd
/Users/shixiongwei/Documents/hctl/demo/blt4/blt-app-viewer/platforms/ios
ShiXiongweideMacBook-Pro:ios shixiongwei$ pod install
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin17/rbconfig.rb:215: warning: Insecure world writable dir /Users/shixiongwei/ConfigDefine/SXWConfig/hadoop-3.1.1/bin in PATH, mode 040777
Analyzing dependencies
Downloading dependencies
Using AMapFoundation (1.5.5)
Using AMapLocation (2.6.1)
Using SDWebImage (3.7.5)
Using SocketRocket (0.4.2)
Using WeexPluginLoader (0.0.1.9.1)
Using WeexSDK (0.19.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.
ShiXiongweideMacBook-Pro:ios shixiongwei$ pod install
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin17/rbconfig.rb:215: warning: Insecure world writable dir /Users/shixiongwei/ConfigDefine/SXWConfig/hadoop-3.1.1/bin in PATH, mode 040777
Analyzing dependencies
Downloading dependencies
Using AMapFoundation (1.5.5)
Using AMapLocation (2.6.1)
Using SDWebImage (3.7.5)
Using SocketRocket (0.4.2)
Using WeexPluginLoader (0.0.1.9.1)
Installing WeexSDK 0.18.0.3 (was 0.19.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.
步驟五:
Xcode項目運行。不報錯了。