Weex编译后,Xcode工程项目编译报错 -[UIView frame] must be used from main thread only

我就是我 2022-05-15 19:11 886阅读 0赞

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中,终端打印报错信息如下:

  1. 2018-10-30 21:46:52.659009+0800 WeexDemo[10443:462845] [DYMTLInitPlatform] platform initialization successful
  2. 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)
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. =================================================================
  11. Main Thread Checker: UI API called on a background thread: -[UIView frame]
  12. PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
  13. Backtrace:
  14. 4 WeexDemo 0x0000000100b52fa8 +[WXBridgeContext checkEmptyScreen:] + 260
  15. 5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
  16. 6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
  17. 7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
  18. 8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
  19. 9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
  20. 10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
  21. 11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
  22. 12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
  23. 13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
  24. 14 Foundation 0x00000001becbb5a0 <redacted> + 336
  25. 15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
  26. 16 CoreFoundation 0x00000001be19a538 <redacted> + 88
  27. 17 CoreFoundation 0x00000001be199e1c <redacted> + 176
  28. 18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
  29. 19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
  30. 20 Foundation 0x00000001beb886a4 <redacted> + 300
  31. 21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
  32. 22 Foundation 0x00000001becbb3b0 <redacted> + 1040
  33. 23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
  34. 24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
  35. 25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
  36. 2018-10-30 21:46:54.152344+0800 WeexDemo[10443:462862] [reports] Main Thread Checker: UI API called on a background thread: -[UIView frame]
  37. PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
  38. Backtrace:
  39. 4 WeexDemo 0x0000000100b52fa8 +[WXBridgeContext checkEmptyScreen:] + 260
  40. 5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
  41. 6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
  42. 7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
  43. 8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
  44. 9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
  45. 10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
  46. 11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
  47. 12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
  48. 13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
  49. 14 Foundation 0x00000001becbb5a0 <redacted> + 336
  50. 15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
  51. 16 CoreFoundation 0x00000001be19a538 <redacted> + 88
  52. 17 CoreFoundation 0x00000001be199e1c <redacted> + 176
  53. 18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
  54. 19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
  55. 20 Foundation 0x00000001beb886a4 <redacted> + 300
  56. 21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
  57. 22 Foundation 0x00000001becbb3b0 <redacted> + 1040
  58. 23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
  59. 24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
  60. 25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
  61. =================================================================
  62. Main Thread Checker: UI API called on a background thread: -[UIView subviews]
  63. PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
  64. Backtrace:
  65. 4 WeexDemo 0x0000000100b53054 +[WXBridgeContext checkEmptyScreen:] + 432
  66. 5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
  67. 6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
  68. 7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
  69. 8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
  70. 9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
  71. 10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
  72. 11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
  73. 12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
  74. 13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
  75. 14 Foundation 0x00000001becbb5a0 <redacted> + 336
  76. 15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
  77. 16 CoreFoundation 0x00000001be19a538 <redacted> + 88
  78. 17 CoreFoundation 0x00000001be199e1c <redacted> + 176
  79. 18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
  80. 19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
  81. 20 Foundation 0x00000001beb886a4 <redacted> + 300
  82. 21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
  83. 22 Foundation 0x00000001becbb3b0 <redacted> + 1040
  84. 23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
  85. 24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
  86. 25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
  87. 2018-10-30 21:46:54.291277+0800 WeexDemo[10443:462862] [reports] Main Thread Checker: UI API called on a background thread: -[UIView subviews]
  88. PID: 10443, TID: 462862, Thread name: com.taobao.weex.bridge, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
  89. Backtrace:
  90. 4 WeexDemo 0x0000000100b53054 +[WXBridgeContext checkEmptyScreen:] + 432
  91. 5 WeexDemo 0x0000000100b51cc8 __43+[WXBridgeContext mountContextEnvironment:]_block_invoke_3 + 3188
  92. 6 JavaScriptCore 0x00000001c5514f3c <redacted> + 28
  93. 7 JavaScriptCore 0x00000001c54a912c <redacted> + 156
  94. 8 WeexDemo 0x0000000100c52284 -[WXJSCoreBridge executeJavascript:withSourceURL:] + 376
  95. 9 WeexDemo 0x0000000100b4b674 __56-[WXBridgeContext createInstance:template:options:data:]_block_invoke + 3460
  96. 10 WeexDemo 0x0000000100b4e420 -[WXBridgeContext callJSMethod:args:onContext:completion:] + 908
  97. 11 WeexDemo 0x0000000100b4a418 -[WXBridgeContext createInstance:template:options:data:] + 4472
  98. 12 WeexDemo 0x0000000100b5489c __56-[WXBridgeManager createInstance:template:options:data:]_block_invoke + 392
  99. 13 WeexDemo 0x0000000100b54018 +[WXBridgeManager _performBlockOnBridgeThread:] + 224
  100. 14 Foundation 0x00000001becbb5a0 <redacted> + 336
  101. 15 CoreFoundation 0x00000001be19a5b8 <redacted> + 24
  102. 16 CoreFoundation 0x00000001be19a538 <redacted> + 88
  103. 17 CoreFoundation 0x00000001be199e1c <redacted> + 176
  104. 18 CoreFoundation 0x00000001be194ce8 <redacted> + 1040
  105. 19 CoreFoundation 0x00000001be1945b8 CFRunLoopRunSpecific + 436
  106. 20 Foundation 0x00000001beb886a4 <redacted> + 300
  107. 21 WeexDemo 0x0000000100b53a9c -[WXBridgeManager _runLoopThread] + 380
  108. 22 Foundation 0x00000001becbb3b0 <redacted> + 1040
  109. 23 libsystem_pthread.dylib 0x00000001bde252fc <redacted> + 128
  110. 24 libsystem_pthread.dylib 0x00000001bde2525c _pthread_start + 48
  111. 25 libsystem_pthread.dylib 0x00000001bde28d08 thread_start + 4
  112. 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
  113. addRouteRecord@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4180:14
  114. file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4151:19
  115. forEach@[native code]
  116. createRouteMap@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4150:17
  117. createMatcher@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:4371:27
  118. VueRouter@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:5465:31
  119. file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:3026:41
  120. __webpack_require__@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:22:34
  121. file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:2993:33
  122. __webpack_require__@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:22:34
  123. file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:65:37
  124. global code@file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276:66:12
  125. file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js?random=648861276
  126. instanceId:0
  127. options:{
  128. bundleType = Vue;
  129. bundleUrl = "file:///var/containers/Bundle/Application/4D5E25DD-7AEB-4F57-B3FF-D879B54E6570/WeexDemo.app/bundlejs/index.js";
  130. debug = 1;
  131. env = {
  132. appName = "\U4e2d\U5f69\U7f51";
  133. appVersion = "1.0.0";
  134. deviceHeight = 1334;
  135. deviceModel = "iPhone8,1";
  136. deviceWidth = 750;
  137. logLevel = log;
  138. osName = iOS;
  139. osVersion = "12.0";
  140. platform = iOS;
  141. scale = 2;
  142. weexVersion = "0.18.0";
  143. };
  144. }
  145. data:(null)
  146. (
  147. service,
  148. clearTimeout,
  149. setInterval,
  150. clearInterval,
  151. services,
  152. BroadcastChannel,
  153. weex,
  154. setTimeout,
  155. Vue,
  156. getJSFMVersion,
  157. "__WEEX_CALL_JAVASCRIPT__"
  158. )

现象:
iOS项目在手机端运行,直接白屏。

问题查找:

步骤一:

在Weex项目中,执行weex run ios指令时候,终端中打印出如下信息:

  1. 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
  2. Analyzing dependencies
  3. Downloading dependencies
  4. Using AMapFoundation (1.5.5)
  5. Using AMapLocation (2.6.1)
  6. Using SDWebImage (3.7.5)
  7. Using SocketRocket (0.4.2)
  8. Using WeexPluginLoader (0.0.1.9.1)
  9. Installing WeexSDK 0.19.0 (was 0.18.0.3)
  10. Generating Pods project
  11. Integrating client project
  12. Sending stats
  13. Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.
  14. ? Choose one of the following devices (Use arrow keys)

步骤二:

检查Xcode中Podfile 文件。如下:

  1. source 'git@github.com/CocoaPods/Specs.git'
  2. platform :ios, '8.0'
  3. #inhibit_all_warnings!
  4. def common
  5. pod 'WeexSDK',
  6. pod 'WeexPluginLoader'
  7. pod 'SDWebImage', '3.7.5'
  8. pod 'SocketRocket', '0.4.2'
  9. pod 'AMapLocation' #定位SDK
  10. end
  11. target 'WeexDemo' do
  12. common
  13. end
  14. target 'WeexUITestDemo' do
  15. common
  16. 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文件如下:

  1. source 'git@github.com/CocoaPods/Specs.git'
  2. platform :ios, '8.0'
  3. #inhibit_all_warnings!
  4. def common
  5. pod 'WeexSDK', '0.18.0.3'
  6. pod 'WeexPluginLoader'
  7. pod 'SDWebImage', '3.7.5'
  8. pod 'SocketRocket', '0.4.2'
  9. pod 'AMapLocation' #定位SDK
  10. end
  11. target 'WeexDemo' do
  12. common
  13. end
  14. target 'WeexUITestDemo' do
  15. common
  16. end

步骤四:

进入到Xcode项目根目录:
在终端中,输入指令pod install ,更新cocoapods相关库。
终端信息如下:

  1. ShiXiongweideMacBook-Pro:ios shixiongwei$ pwd
  2. /Users/shixiongwei/Documents/hctl/demo/blt4/blt-app-viewer/platforms/ios
  3. ShiXiongweideMacBook-Pro:ios shixiongwei$ pod install
  4. /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
  5. Analyzing dependencies
  6. Downloading dependencies
  7. Using AMapFoundation (1.5.5)
  8. Using AMapLocation (2.6.1)
  9. Using SDWebImage (3.7.5)
  10. Using SocketRocket (0.4.2)
  11. Using WeexPluginLoader (0.0.1.9.1)
  12. Using WeexSDK (0.19.0)
  13. Generating Pods project
  14. Integrating client project
  15. Sending stats
  16. Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.
  17. ShiXiongweideMacBook-Pro:ios shixiongwei$ pod install
  18. /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
  19. Analyzing dependencies
  20. Downloading dependencies
  21. Using AMapFoundation (1.5.5)
  22. Using AMapLocation (2.6.1)
  23. Using SDWebImage (3.7.5)
  24. Using SocketRocket (0.4.2)
  25. Using WeexPluginLoader (0.0.1.9.1)
  26. Installing WeexSDK 0.18.0.3 (was 0.19.0)
  27. Generating Pods project
  28. Integrating client project
  29. Sending stats
  30. Pod installation complete! There are 5 dependencies from the Podfile and 6 total pods installed.

步骤五:

Xcode项目运行。不报错了。

后记:
本篇主要是记录遇到的问题,原理可能没讲出来,或者有其他错误的地方。反正这次是指定WeekSDK版本,重新编译后,就解决了。如有错误,敬请原理,同时,知道的,请告知,指正。谢谢。

发表评论

表情:
评论列表 (有 0 条评论,886人围观)

还没有评论,来说两句吧...

相关阅读