appium / WebDriverAgent

A WebDriver server for iOS and tvOS
Other
1.2k stars 373 forks source link

lldb-rpc-server taking up 2.14GB memory when running WebDriverAgent #550

Closed guanzhangrtk closed 2 years ago

guanzhangrtk commented 2 years ago

OS: macOS Big Sur 11.5.2 Xcode: 13.1

I've built WebDriverAgent from https://github.com/appium/WebDriverAgent and after deploying it to iOS real device, I noticed that lldb-rpc-server is using 2.14GB memory on the Mac -- is this expected and is there any way to tweak this? Thanks in advance for any feedback, thanks!

image

guanzhangrtk commented 2 years ago

@mykola-mokhnach thanks for the ticket transfer. I originally was going to file the issue in the WebDriverAgent repo as opposed to the appium repo but when I attempt to file the ticket I saw this -- perhaps it should be removed then if this issue tracker is now being tracked? Thanks a lot! image

jlipps commented 2 years ago

Is this a service that WDA or appium uses? I'm not familiar with it.

guanzhangrtk commented 2 years ago

@jlipps LLDB is the default debugger of Xcode so I assume lldb-rpc-server is a process spawned while the application is running. You should be able to see it after you have successfully built and have WDA running via Xcode.

Thanks!

KazuCocoa commented 2 years ago

Could be related to https://developer.apple.com/forums/thread/114264 ?

KazuCocoa commented 2 years ago

mm, google resulted lldb-rpc-server high memory usage related keyword search as https://www.google.com/search?q=lldb-rpc-server+high+memory+usage&sxsrf=AOaemvLjKeFKaxq5RD4rn370vuLI59WW7g%3A1641622221134&source=hp&ei=zSrZYe_EBeif0PEPteyn0As&iflsig=ALs-wAMAAAAAYdk43Vxzofr8Bg0oYCZGg9KEZR9HEYd2&oq=lldb-r&gs_lcp=Cgdnd3Mtd2l6EAMYATIFCAAQgAQyBQgAEIAEMgUIABCABDIFCAAQgAQyBQgAEIAEMgUIABCABDIFCAAQywEyBAgAEB4yBAgAEB4yBAgAEB46BAgjECc6DgguEIAEELEDEMcBENEDOg4ILhCABBCxAxDHARCjAjoLCC4QgAQQsQMQgwE6CwguEIAEEMcBEKMCOgsILhCxAxDHARCjAjoICC4QgAQQsQM6CAgAEIAEELEDOgsILhCABBDHARDRAzoLCAAQgAQQsQMQgwFQAFjQD2CcKGgAcAB4AYABiwSIAecMkgELMi4xLjAuMS4xLjGYAQCgAQE&sclient=gws-wiz

So, probably it is general Xcode/LLDB stuff rather than Appium/WDA specific.

KazuCocoa commented 2 years ago

If it was xcodebuild specific issue, potentially you can try other tools such as go-ios and manage appium/WDA by yourself via them. https://appium.io/docs/en/advanced-concepts/wda-custom-server/

guanzhangrtk commented 2 years ago

If it was xcodebuild specific issue, potentially you can try other tools such as go-ios and manage appium/WDA by yourself via them. https://appium.io/docs/en/advanced-concepts/wda-custom-server/

Thanks for the pointers @KazuCocoa, I'll take a look and see if I can run WDA outside of Xcode. BTW while I have you here, are there any documentations on how to tweak/optimize WDA such that they perform "as fast as possible" on real devices? I know that a lot of it is due to limitations on the Apple XCTest side but I was wondering how much tweaking can be done on the WDA side. Or if you prefer I can open another issue on this query, thanks!

KazuCocoa commented 2 years ago

they perform "as fast as possible" on real devices?

What kind of actions/commands do you imagine?

xcuitest driver has reference sections such as https://github.com/appium/appium-xcuitest-driver#references . They have links to XCTest API. In such mobile commands simply call XCTest API. In such a case, nothing can do in appium side. Other commands such as W3C actions parse and transfer them to XCTest (private) apis to achieve them. In such cases also WDA's own code itself is probably not heavy as XCTest internal stuff.

Actually, WDA has some hacks to try to improve performance such as animationCoolOffTimeout, but Appium/WDA has been trying to reduce Appium/WDA hack and refer to vanilla XCTest as possible (when it could). Afaik, Appium/WDA has workarounds for various iOS/iPadOS versions, so when we drop old iOS versions, for example, some code could simplify, but probably most of them do not affect performance.

Anyway, all of WDA's end points are XCTest APIs (public/private), so Appium/WDA itself cannot do so much. Appium/WDA specific action such as getting source code could be slow. Then, excludedAttributes in https://github.com/appium/appium-xcuitest-driver#arguments-4 should help, for example.

You can create a new issue in appium repo if you found a good way to improve performance in Appium/WDA.

KazuCocoa commented 2 years ago

Close this for now since the lldb-rpc-server itself is not Appium/WDA specific, it is more general Xcode/LLDB stuff according to some articles.