移动地图时,Xcode 9模拟器上的GoogleMaps使用了超过100%的CPU [英] GoogleMaps on simulator in Xcode 9 uses over 100% of CPU when moving the map

查看:252
本文介绍了移动地图时,Xcode 9模拟器上的GoogleMaps使用了超过100%的CPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我现在已经将我的项目转换为在Xcode 9中使用Swift 4,并且已经开始测试我的应用程序。这是一个包含四个不同标签的大应用程序,几乎所有内容都按预期工作。其中一个标签是使用GoogleMaps的地图。我从来没有遇到任何问题,但是当使用Xcode 9构建并在Simulator中显示时,它在移动地图时使用了100%以上的CPU,并且它非常滞后。
这是在模拟器上运行时的调试导航器。
我们做了一些自定义绘图,但没有102%的绘图。





这只在我更新到Xcode 9和Swift 4后才开始发生。
在iPhone 7,8或X 模拟器的Xcode 9中进行调试时,所有使用iOS 11,它只有100%以上的CPU,并且每当我尝试移动它时,它都会使UI停止更新大约一秒钟。我开始拖动手势,但UI只更新一次。有效地给我介绍 1fps



然而,在iPhone 6 模拟器上在Xcode 9中进行调试时 iOS 9 相比,移动地图时可达到约90%,而且几乎没有滞后。我猜我在这里得到20-30 fps。 (这可能与我在Xcode 8上的模拟器中获得的fps相同。)模拟器上的地图从未真正流畅。)当在实际设备上运行时(iPhone 7 ,iOS 11)时,CPU在不断移动地图时使用约40%,并且工作非常流畅,根本没有滞后(60fps)。

我也得到这个在输出结果中,只要我用地图打开标签,但我认为它与这个特定问题无关:

 主线程检查器:在后台线程上调用UI API: -  [UIApplication applicationState] 
PID:*****,TID:*******,线程名称:com.google.Maps.LabelingBehavior,队列名称:com.apple.root.default-qos.overcommit,QoS:21

这表示GoogleMapsAPI调用 [UIApplication applicationState] 在后台线程上。



我使用最新版GoogleMaps: 2.4.0 即可。据我所知,这个版本可能不支持Xcode 9 / Swift 4等,但我找不到任何有关新版本的信息。 div> 更新:在Xcode 9.1 beta 2中修正了这个问题。



OpenGLES .framework 导致它跳过加载LLVM JIT并回退到解释着色器。这对模拟器有着严重的性能影响,因为它完全是软件渲染的OpenGL(包括CoreAnimation,SceneKit等)。

编辑 :为了澄清,这些症状正是您所描述的:100%或更高的CPU使用率和<1fps的渲染。这会影响Google Maps SDK和MapKit。



作为临时解决方法,您可以从Beta 3中复制 libCoreVMClient.dylib 进入Xcode 9 GM,性能应该恢复到之前的水平。对于iOS,它位于: Xcode [-beta] .app / Contents / Developer /平台/ iPhoneOS.platform /开发/库/ CoreSimulator /概况/运行时/ iOS.simruntime /内容/资源/ RuntimeRoot /系统/资源库/框架/ OpenGLES.framework / libCoreVMClient.dylib



对于tvOS,它位于: Xcode [-beta] .app / Contents / Developer / Platforms / AppleTVOS.platform / Developer / Library / CoreSimulator / Profiles / Runtime / tvOS.simruntime / Contents / Resources / RuntimeRoot / System / Library / Frameworks / OpenGLES.framework / libCoreVMClient.dylib



位于: Xcode [-beta] .app / Contents / Developer / Platforms / WatchOS.platform / Developer / Library / CoreSimulator / Profiles / Runtimes / watchOS.simruntime / Contents / Resources / RuntimeRoot / System / Library / Frameworks / OpenGLES.framework / libCoreVMClient.dylib


So I've now converted my project to use Swift 4 in Xcode 9, and have started testing my app. It's a big app with four distinct tabs, and nearly everything is working as expected. One of the tabs is a map, using GoogleMaps. I have never had any trouble with it, but when built with Xcode 9 and shown in Simulator, it uses over 100% of CPU when moving the map, and it lags very much. Here is the debug navigator when running on a simulator. We do some custom drawing, but not 102% worth of drawing.

This only started happening after I updated to Xcode 9 and Swift 4. When debugging in Xcode 9 on an iPhone 7, 8 or X simulator, all with iOS 11, it goes just over 100% CPU, and it completely stops the UI from updating for about one second each time I try to move it. I start the drag-gesture, but the UI only updates once a second. Effectively giving me about 1fps.

However, when debugging in Xcode 9 on an iPhone 6 simulator with iOS 9, it gets up to ~90% when moving the map and not lagging nearly as much. I'm guessing I get about 20-30 fps here. (This might be the same fps I get in simulators on Xcode 8. Map has never been really smooth on simulator..)

When running on an actual device (iPhone 7, iOS 11), the CPU uses about 40% when constantly moving the map, and is working very smooth with no lags at all (60fps).

I also get this in the output as soon as I open the tab with the map, but I think it's irrelevant to this particular question:

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: *****, TID: *******, Thread name: com.google.Maps.LabelingBehavior, Queue name: com.apple.root.default-qos.overcommit, QoS: 21

This says that GoogleMapsAPI calls [UIApplication applicationState] on a background thread..

I am using the latest version of GoogleMaps: 2.4.0. As far as I know, this version may not support Xcode 9/Swift 4 etc, but I can't find anything about a new version.

解决方案

Update: This issue is fixed in Xcode 9.1 beta 2

There is a bug in OpenGLES.framework that causes it to skip loading the LLVM JIT and fall back to interpreting shaders. This has a severe performance impact on the Simulator since it is entirely software-rendered OpenGL (this includes CoreAnimation, SceneKit, etc).

edit: To clarify, the symptoms of this are exactly what you describe: 100% or greater CPU usage and <1fps rendering. This affects the Google Maps SDK and MapKit.

As a temporary workaround you can copy libCoreVMClient.dylib from Beta 3 into the Xcode 9 GM and performance should be restored to what it was previously. This must be done for each platform runtime separately.

For iOS this is located at: Xcode[-beta].app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib

For tvOS this is located at: Xcode[-beta].app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/tvOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib

For watchOS this is located at: Xcode[-beta].app/Contents/Developer/Platforms/WatchOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/watchOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib

这篇关于移动地图时,Xcode 9模拟器上的GoogleMaps使用了超过100%的CPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆