Weex编译后,Xcode工程项目编译报错 -[UIView frame] must be used from main thread only
Weex编译后,Xcode工程项目编译报错–[UIView frame] must be used from main thread only
大致报错有以下两点。
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中,终端打印报错信息如下:
2018-10-30 21:46:52.659009+0800 WeexDemo[10443:462845] [DYMTLInitPlatform] platform initialization successful
2018-10-30 21:46:52.848983+0800 WeexDemo[10443:462862] <Weex>[info]WXBridgeContext.m:1058, jsLog: START JS FRAMEWORK 0.26.17, Build 2018-06-21 17:37. (Vue: 2.5.13-weex.5, Rax: 0.4.20) START JS FRAMEWORK 0.26.17, Build 2018-06-21 17:37. (Vue: 2.5.13-weex.5, Rax: 0.4.20)
2018-10-30 21:46:52.857556+0800 WeexDemo[10443:462862] <Weex>[info]WXBridgeContext.m:1055, jsLog: Start windmill weex-vue-plugin (0.1.6) framework. Build at 2018-06-21 17:08 __LOG
2018-10-30 21:46:53.998771+0800 WeexDemo[10443:462862] <Weex>[info]WXBridgeContext.m:750, No send queue for instance:<WXSDKInstance: 0x10bd0fc50; id = 0; rootView = (null); url= file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276>, may it has been destroyed so method:fireEvent is ignored
2018-10-30 21:46:54.014921+0800 WeexDemo[10443:462833] <Weex>[log]WXSDKInstance.m:250, Start rendering page:file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276
2018-10-30 21:46:54.126342+0800 WeexDemo[10443:462862] <Weex>[info]WXBridgeContext.m:1055, jsLog: [JS Framework] using unregistered weex module "bindingx" __WARN
2018-10-30 21:46:54.126608+0800 WeexDemo[10443:462862] <Weex>[info]WXBridgeContext.m:1055, jsLog: [JS Framework] using unregistered weex module "binding" __WARN
2018-10-30 21:46:54.126913+0800 WeexDemo[10443:462862] <Weex>[info]WXBridgeContext.m:1055, jsLog: [JS Framework] using unregistered weex module "expressionBinding" __WARN
2018-10-30 21:46:54.128476+0800 WeexDemo[10443:462862] <Weex>[info]WXBridgeContext.m:1055, jsLog: [JS Framework] using unregistered weex module "swipeBack" __WARN
=================================================================
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, QoS: 0
Backtrace:
4 WeexDemo 0x0000000100b52fa8 +[WXBridgeContext checkEmptyScreen:] + 260
5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
14 Foundation 0x00000001becbb5a0 <redacted> + 336
15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
16 CoreFoundation 0x00000001be19a538 <redacted> + 88
17 CoreFoundation 0x00000001be199e1c <redacted> + 176
18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
20 Foundation 0x00000001beb886a4 <redacted> + 300
21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
22 Foundation 0x00000001becbb3b0 <redacted> + 1040
23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
2018-10-30 21:46:54.152344+0800 WeexDemo[10443:462862] [reports] 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, QoS: 0
Backtrace:
4 WeexDemo 0x0000000100b52fa8 +[WXBridgeContext checkEmptyScreen:] + 260
5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
14 Foundation 0x00000001becbb5a0 <redacted> + 336
15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
16 CoreFoundation 0x00000001be19a538 <redacted> + 88
17 CoreFoundation 0x00000001be199e1c <redacted> + 176
18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
20 Foundation 0x00000001beb886a4 <redacted> + 300
21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
22 Foundation 0x00000001becbb3b0 <redacted> + 1040
23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView subviews]
PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 WeexDemo 0x0000000100b53054 +[WXBridgeContext checkEmptyScreen:] + 432
5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
14 Foundation 0x00000001becbb5a0 <redacted> + 336
15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
16 CoreFoundation 0x00000001be19a538 <redacted> + 88
17 CoreFoundation 0x00000001be199e1c <redacted> + 176
18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
20 Foundation 0x00000001beb886a4 <redacted> + 300
21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
22 Foundation 0x00000001becbb3b0 <redacted> + 1040
23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
2018-10-30 21:46:54.291277+0800 WeexDemo[10443:462862] [reports] Main Thread Checker: UI API called on a background thread: -[UIView subviews]
PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 WeexDemo 0x0000000100b53054 +[WXBridgeContext checkEmptyScreen:] + 432
5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
14 Foundation 0x00000001becbb5a0 <redacted> + 336
15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
16 CoreFoundation 0x00000001be19a538 <redacted> + 88
17 CoreFoundation 0x00000001be199e1c <redacted> + 176
18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
20 Foundation 0x00000001beb886a4 <redacted> + 300
21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
22 Foundation 0x00000001becbb3b0 <redacted> + 1040
23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
2018-10-30 21:46:54.365925+0800 WeexDemo[10443:462862] <Weex>[error]WXMonitor.m:294, [WX_KEY_EXCEPTION_WXBRIDGE] [file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4180:14] ReferenceError: Can't find variable: process
addRouteRecord@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4180:14
file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4151:19
forEach@[native code]
createRouteMap@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4150:17
createMatcher@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4371:27
VueRouter@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:5465:31
file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:3026:41
__webpack_require__@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:22:34
file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:2993:33
__webpack_require__@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:22:34
file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:65:37
global code@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:66:12
file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276
instanceId:0
options:{
bundleType = Vue;
bundleUrl = "file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js";
debug = 1;
env = {
appName = "\U4e2d\U5f69\U7f51";
appVersion = "1.0.0";
deviceHeight = 1334;
deviceModel = "iPhone8,1";
deviceWidth = 750;
logLevel = log;
osName = iOS;
osVersion = "12.0";
platform = iOS;
scale = 2;
weexVersion = "0.18.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项目运行。不报错了。
后记:
本篇主要是记录遇到的问题,原理可能没讲出来,或者有其他错误的地方。反正这次是指定WeekSDK版本,重新编译后,就解决了。如有错误,敬请原理,同时,知道的,请告知,指正。谢谢。
还没有评论,来说两句吧...