GADS icon indicating copy to clipboard operation
GADS copied to clipboard

Issues with Appium server/MongoDB

Open shamanec opened this issue 9 months ago • 24 comments

@shamanec Hello,

First of all, I would like to express my appreciation for the great work you've done with this platform. It has been incredibly helpful for automating and managing a large number of devices. However, I've encountered a couple of issues that I would like to report:

Appium issue: After several interactions with the Android/iOS devices, Appium stops functioning properly. The server seems to freeze or crash, preventing further interactions with the devices. It would be great if you could investigate this issue. I’ve been using the current version of the WDA for iOS, but unfortunately, I’m still encountering some issues. Even after updating, it seems like the problem persists, and I’m unable to proceed with certain interactions. (same problem iPhone 12 Mini - 17.7.2, iPhone 13 - 18.3.1 and iPhone SE - 17.4.1).

Image

Image

MongoDB errors: I've also experienced occasional errors with the MongoDB database. It sometimes throws unexpected errors, which might be related to the heavy load or certain actions performed within the system. Every 2-3 minutes, the health status of the devices turns false, which causes the devices to be marked as N/A.

Image

Image

Image

It would be awesome if you could look into these problems. If you need more details or logs, feel free to reach out.

Once again, thank you for your hard work on this project. It’s been a game-changer for managing devices.

Originally posted by @lmawebdev in #149

shamanec avatar Mar 17 '25 08:03 shamanec

Hey @lmawebdev, I am moving this to a separate issue! I haven't seen that issue with Appium and interactions but I will think about what could cause it. When you see those errors you can check in the browser debugger tools what kind of errors do the endpoint calls return and let me know, you can also send me provider logs and device/device Appium logs for this.

Regarding MongoDB, I really have no idea how much it can handle 😅 What is a "large" number of devices?

shamanec avatar Mar 17 '25 08:03 shamanec

Hello, @shamanec

Thank you for your quick response!

I’m attaching the log captures for both the request and Appium. It seems that the provider isn't showing any errors.

Image

Image

I currently have 11 devices connected (3 iOS and the rest Android).

lmawebdev avatar Mar 17 '25 09:03 lmawebdev

Hmm, 11 devices shouldn't be that many, I wonder why Mongo would fail but I will look into this.

Regarding the errors - the Appium log you've attached is only up until it was started, but it doesn't contain any errors. The Home request though seems to have a problem. Are you using WebDriverAgent from my fork or WebDriverAgent from the mainstream Appium repository?

shamanec avatar Mar 17 '25 09:03 shamanec

I have your WebDriverAgent from fork.

To reproduce the issue:

It appears that when I interact with both an Android and an iOS device at the same time, the system starts to fail. Or more than 2 devices at same time. Even when I exit one device, it seems to cause issues with the other device.

I’m attaching the log captures:

Image

Image

Android requests:

Image

lmawebdev avatar Mar 17 '25 09:03 lmawebdev

Okay, okay, that's helpful! I will look into it when I can, thanks for the report!

shamanec avatar Mar 17 '25 09:03 shamanec

@lmawebdev hey, mate, I think I caught the issue with the interaction failing and the provider dying with slice out of bounds , you can check the latest release 👌

shamanec avatar Mar 27 '25 06:03 shamanec

Hi, @shamanec Thank you for fixing the issue. I really appreciate the time and effort you put into it. I’m about to test the solution and will let you know the results shortly.

lmawebdev avatar Mar 27 '25 09:03 lmawebdev

Hello @shamanec , sorry for the delay, I have only been testing with 2 devices, using them at the same time, and the Appium keeps crashing. I’m using the latest version 3.3.0, and besides what was mentioned, the workspace feature is also failing. I’m attaching evidence. Thanks in advance.

(workspace error) https://github.com/user-attachments/assets/48f78735-0603-4c97-b553-fee610b150d8

Image

Image

Appium error, when I control 2 devices at same time.

Image

lmawebdev avatar Apr 25 '25 08:04 lmawebdev

Honestly this makes no sense, what I could reproduce is fixed now 😓 Can you check with this release? Note that it includes breaking changes, iOS remote control will work only with WebDriverAgent from my fork

shamanec avatar Apr 25 '25 08:04 shamanec

Hi, I’ve tested the test version and the WebDriverAgent, and I’m getting an error on the iOS device with the following message:

{"event":"ios_device_setup","level":"info","msg":"Running setup for device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:01+02:00"} {"event":"ios_device_setup","level":"info","msg":"Pairing device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:03+02:00"} {"event":"install_app_ios","level":"info","msg":"Attempting to install app /Users/qaUser/Desktop/Movilidad/GADS/providers/TempFilesProviders/WebDriverAgent.ipa on device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:05+02:00"} {"event":"ios_device_setup","level":"info","msg":"Successfully started WebDriverAgent for device 00008030-001C6D6C11B9402E forwarded on port 50387","time":"2025-04-25T12:54:05+02:00"} {"event":"ios_device_setup","level":"error","msg":"updateWebDriverAgent: Could not update WebDriverAgent stream settings for device 00008030-001C6D6C11B9402E - updateWebDriverAgentStreamSettings: Could not successfully update WDA stream settings, status code=404","time":"2025-04-25T12:54:05+02:00"} {"event":"ios_device_setup","level":"error","msg":"Did not successfully create WebDriverAgent session or update its stream settings for device 00008030-001C6D6C11B9402E - updateWebDriverAgentStreamSettings: Could not successfully update WDA stream settings, status code=404","time":"2025-04-25T12:54:05+02:00"} {"event":"provider","level":"info","msg":"Resetting LocalDevice for device 00008030-001C6D6C11B9402E with reason: Failed to create WebDriverAgent session or update its stream settings.. Cancelling context, setting ProviderState to init, Healthy to false and updating the DB","time":"2025-04-25T12:54:05+02:00"} {"event":"ios_device_setup","level":"info","msg":"Running setup for device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:06+02:00"} {"event":"ios_device_setup","level":"info","msg":"Pairing device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:08+02:00"} {"event":"install_app_ios","level":"info","msg":"Attempting to install app /Users/qaUser/Desktop/Movilidad/GADS/providers/TempFilesProviders/WebDriverAgent.ipa on device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:10+02:00"} {"event":"ios_device_setup","level":"info","msg":"Successfully started WebDriverAgent for device 00008030-001C6D6C11B9402E forwarded on port 50411","time":"2025-04-25T12:54:10+02:00"} {"event":"ios_device_setup","level":"error","msg":"updateWebDriverAgent: Could not update WebDriverAgent stream settings for device 00008030-001C6D6C11B9402E - updateWebDriverAgentStreamSettings: Could not successfully update WDA stream settings, status code=404","time":"2025-04-25T12:54:10+02:00"} {"event":"ios_device_setup","level":"error","msg":"Did not successfully create WebDriverAgent session or update its stream settings for device 00008030-001C6D6C11B9402E - updateWebDriverAgentStreamSettings: Could not successfully update WDA stream settings, status code=404","time":"2025-04-25T12:54:10+02:00"} {"event":"provider","level":"info","msg":"Resetting LocalDevice for device 00008030-001C6D6C11B9402E with reason: Failed to create WebDriverAgent session or update its stream settings.. Cancelling context, setting ProviderState to init, Healthy to false and updating the DB","time":"2025-04-25T12:54:10+02:00"} {"event":"ios_device_setup","level":"info","msg":"Running setup for device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:11+02:00"} {"event":"ios_device_setup","level":"info","msg":"Pairing device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:13+02:00"} {"event":"install_app_ios","level":"info","msg":"Attempting to install app /Users/qaUser/Desktop/Movilidad/GADS/providers/TempFilesProviders/WebDriverAgent.ipa on device 00008030-001C6D6C11B9402E","time":"2025-04-25T12:54:15+02:00"} {"event":"ios_device_setup","level":"info","msg":"Successfully started WebDriverAgent for device 00008030-001C6D6C11B9402E forwarded on port 50434","time":"2025-04-25T12:54:15+02:00"} {"event":"ios_device_setup","level":"error","msg":"updateWebDriverAgent: Could not update WebDriverAgent stream settings for device 00008030-001C6D6C11B9402E - updateWebDriverAgentStreamSettings: Could not successfully update WDA stream settings, status code=404","time":"2025-04-25T12:54:15+02:00"} {"event":"ios_device_setup","level":"error","msg":"Did not successfully create WebDriverAgent session or update its stream settings for device 00008030-001C6D6C11B9402E - updateWebDriverAgentStreamSettings: Could not successfully update WDA stream settings, status code=404","time":"2025-04-25T12:54:15+02:00"} {"event":"provider","level":"info","msg":"Resetting LocalDevice for device 00008030-001C6D6C11B9402E with reason: Failed to create WebDriverAgent session or update its stream settings.. Cancelling context, setting ProviderState to init, Healthy to false and updating the DB","time":"2025-04-25T12:54:15+02:00"}

I downloaded the .ipa from the repository release, re-signed the .ipa, and since it didn’t work, I also cloned the repository and followed the provider setup guide — both resulted in the same error.

yunki-cmd avatar Apr 25 '25 11:04 yunki-cmd

@yunki-cmd I am not sure you are using the hotfix release, there is a line fmt.Println("Updating Appium settings") that I forgot while testing and it should always appear in your logs like Updating Appium settings {"settings":{"mjpegServerFramerate":30,"mjpegServerScreenshotQuality":30,"mjpegScalingFactor":50}} before that failure and I don't see this in your logs at all. I literally downloaded the release, ran the hub, added the freshly downloaded and resigned ipa, started the provider and it worked the first time. Please double check with ./GADS version that it returns hotfix, also try running the provider with --log-level=debug

{"event":"ios_device_setup","level":"debug","msg":"Creating WebDriverAgent session and updating MJPEG stream settings for device 00008030-0018386C1106402E","time":"2025-04-25T14:38:02+03:00"} {"event":"ios_device_setup","level":"debug","msg":"updateWebDriverAgent: Updating WebDriverAgent session and mjpeg stream settings for device 00008030-0018386C1106402E","time":"2025-04-25T14:38:02+03:00"} Updating Appium settings {"settings":{"mjpegServerFramerate":30,"mjpegServerScreenshotQuality":30,"mjpegScalingFactor":50}} INFO[0010] new client connected conn="&forward.ConnListener{listener:(*net.TCPListener)(0x14003020ea0), quit:(chan interface {})(0x14000405500)}" INFO[0010] Connected to port conn="&net.TCPConn{conn:net.conn{fd:(*net.netFD)(0x14003fa4780)}}" phonePort=8100 {"event":"ios_device_setup","level":"debug","msg":"Successfully created WebDriverAgent session and updated stream settings for device 00008030-0018386C1106402E","time":"2025-04-25T14:38:02+03:00"} {"event":"ios_device_setup","level":"debug","msg":"Waiting until Appium successfully starts for device 00008030-0018386C1106402E","time":"2025-04-25T14:38:02+03:00"}

shamanec avatar Apr 25 '25 11:04 shamanec

Hi, thanks for responding. I am using the test version. When I run the command GADS version, it returns hotfix.

Image

And here the log in debug mode:

logprovider.txt

yunki-cmd avatar Apr 25 '25 15:04 yunki-cmd

@yunki-cmd this log is different than the previous one, it is not full but here WebDriverAgent does not start at all! When you resigned did you provide the correct bundle identifier in the provider config? The ipa from my repo is using com.facebook.WebDriverAgentRunner by default and if you previously were building manually from Xcode and using another, it might be leftover in the configuration? Also you might have provided a different one when resigning?

shamanec avatar Apr 26 '25 04:04 shamanec

@yunki-cmd this log is different than the previous one, it is not full but here WebDriverAgent does not start at all! When you resigned did you provide the correct bundle identifier in the provider config? The ipa from my repo is using com.facebook.WebDriverAgentRunner by default and if you previously were building manually from Xcode and using another, it might be leftover in the configuration? Also you might have provided a different one when resigning?

Hi, I have been testing different ways of signing the WDA, and in all cases I get the same error. I performed tests using both the test and release versions of GADS. I'm using a custom version of WDA, and it's exactly the same signed build in both tests, with the GADS release version, iOS is provisioned correctly. However, with the GADS test version, iOS fails to provision properly.

Image

Log from the provider using the GADS release version: provider.log

yunki-cmd avatar Apr 29 '25 09:04 yunki-cmd

@yunki-cmd Yeah, I think I pinpointed it, when this is merged I will create a new hotfix release so you can check it out. Or you can just checkout the branch from the PR, build and test yourself, sorry about that :(

shamanec avatar Apr 29 '25 13:04 shamanec

@yunki-cmd Yeah, I think I pinpointed it, when this is merged I will create a new hotfix release so you can check it out. Or you can just checkout the branch from the PR, build and test yourself, sorry about that :(

Thank you for taking the time to review and improve the solution. I have encountered a bug related to device control on iOS

Description When accessing the iOS search screen, the device control is completely lost. This issue has only been observed on this specific screen so far.

The issue can be temporarily resolved by manually exiting the search screen, as shown in the attached video. However, even using the refresh button in Appium does not restore device control.

Steps to Reproduce:

1 - From the iOS home screen, swipe down to access the search screen. 2 - Observe that the device control is lost. 3 - The device control is completely lost when accessing the iOS search screen. Using the refresh button in Appium does not restore control.

Additional Information iOS Version: 18.3.1 Device: iPhone SE App Version: GADS 3.3.0 WebDriverAgent: Custom WDA Environment: macOS 15.3.1 Sequoia

video drive

yunki-cmd avatar Apr 29 '25 14:04 yunki-cmd

@yunki-cmd Actually its not the full remote control, just the Home navigation. Since the Home request takes longer to fail and actions are synchronous, if you try to do something while the server still hasn't responded, it will probably not work. The whole interaction is based on WebDriverAgent so if this in particular is failing on this search screen, there is nothing I can do :(

https://github.com/user-attachments/assets/664de4cd-0738-4dc7-85eb-e7461d99a8fe

shamanec avatar Apr 29 '25 14:04 shamanec

Latest changes are now here

shamanec avatar May 02 '25 04:05 shamanec

Latest changes are now here

The same error persists. I downloaded the version you just uploaded, and the same issue appears.


GADS Version

  • Version: GADS v4.0.0-prerelease.1
Image

Environment

  • Operating System: macOS Sequoare 15.3.1
  • iOS: 18.3.1
  • WebDriverAgent (WDA): WDA Custom
  • WDA Bundle ID: com.facebook.WebDriverAgentRunner

Commands Used

Command to start the hub:

sudo ./GADS hub --host-address=192.168.1.135 --port=10000 --mongo-db="localhost:27017" --files-dir="/Users/qaUser/Desktop/Movilidad/GADS/hub/tempFront"

Command to start the provider:

sudo ./GADS provider --nickname="provider1" --provider-folder="/Users/qaUser/Desktop/Movilidad/GADS/providers/TempFilesProviders" --log-level=debug --hub="http://192.168.1.135:10000"

Observations

  • The provider fails to start iOS and throws the same error.

  • The Appium log is empty. Following the traces, it is observed that a request is made to an Appium server, but it does not reflect the logs when the server is started.

  • During all retries on iOS, no installation of the WDA is observed on the physical device.

  • provider log: provider.log


To rule out a possible issue with the WDA signature, I tested with a local installation using go-ios and the WDA built in the provider-folder:

  1. Downloaded the official go-ios repository.

  2. Installed the WDA from the provider-folder using the following commands:

    # Start tunnel
    sudo ./go-ios tunnel start
    
    # Install WDA
    ./go-ios install --udid 00008030-001C6D6C11UDIDIOS --path /Users/qaUser/Desktop/Movilidad/GADS/providers/TempFilesProviders/WebDriverAgent.ipa
    

    Command Output:

    {"appPath":"/Users/qaUser/Desktop/Movilidad/GADS/providers/TempFilesProviders/WebDriverAgent.ipa","device":"00008030-001C6D6C11UDIDIOS","level":"info","msg":"installing","time":"2025-05-02T20:09:05+02:00"}
    {"level":"info","msg":"installing","percentComplete":5,"status":"CreatingStagingDirectory","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":15,"status":"ExtractingPackage","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":20,"status":"InspectingPackage","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":30,"status":"PreflightingApplication","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":40,"status":"VerifyingApplication","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":50,"status":"CreatingContainer","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":60,"status":"InstallingApplication","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":70,"status":"PostflightingApplication","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":80,"status":"SandboxingApplication","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":90,"status":"GeneratingApplicationMap","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installing","percentComplete":100,"status":"InstallComplete","time":"2025-05-02T20:09:06+02:00"}
    {"level":"info","msg":"installation successful","time":"2025-05-02T20:09:06+02:00"}
    

Note

Using go-ios locally, the WDA is successfully installed on the mobile device.
Switching GADS to version 3.3.0 (or any earlier version), the same custom WDA works correctly.

yunki-cmd avatar May 02 '25 20:05 yunki-cmd

@yunki-cmd thanks for the comprehensive report! There is some discrepancy between what you are saying and what I can see in the attached provider.log file - you say that WebDriverAgent does not get installed on the device but in the logs I see: {"event":"ios_device_setup","level":"debug","msg":"Successfully installed WebDriverAgent on device 00008030-001C6D6C11UDIDIOS","time":"2025-05-02T20:05:45+02:00"} {"event":"ios_device_setup","level":"debug","msg":"Waiting until WebDriverAgent successfully starts for device 00008030-001C6D6C11UDIDIOS","time":"2025-05-02T20:05:45+02:00"} {"event":"ios_device_setup","level":"info","msg":"Successfully started WebDriverAgent for device 00008030-001C6D6C11UDIDIOS forwarded on port 56733","time":"2025-05-02T20:05:47+02:00"}

I tried dropping my Mongo, running 3.3.0 then switching to the prerelease version and I cannot reproduce, WDA gets installed, runs and the stream settings are updated successfully. The only thing I can think of is some discrepancy in the DB data from some previous version that is not properly handled in prerelease. There are probably only two things going forward:

  1. Drop your MongoDB data and try directly running the latest version and see if it still happens
  2. If it still happens - lets organise some live session where I can try and debug this on your machine if possible so we can finally fix this :)

shamanec avatar May 03 '25 06:05 shamanec

@yunki-cmd thanks for the comprehensive report! There is some discrepancy between what you are saying and what I can see in the attached provider.log file - you say that WebDriverAgent does not get installed on the device but in the logs I see: {"event":"ios_device_setup","level":"debug","msg":"Successfully installed WebDriverAgent on device 00008030-001C6D6C11UDIDIOS","time":"2025-05-02T20:05:45+02:00"} {"event":"ios_device_setup","level":"debug","msg":"Waiting until WebDriverAgent successfully starts for device 00008030-001C6D6C11UDIDIOS","time":"2025-05-02T20:05:45+02:00"} {"event":"ios_device_setup","level":"info","msg":"Successfully started WebDriverAgent for device 00008030-001C6D6C11UDIDIOS forwarded on port 56733","time":"2025-05-02T20:05:47+02:00"}

I tried dropping my Mongo, running 3.3.0 then switching to the prerelease version and I cannot reproduce, WDA gets installed, runs and the stream settings are updated successfully. The only thing I can think of is some discrepancy in the DB data from some previous version that is not properly handled in prerelease. There are probably only two things going forward:

  1. Drop your MongoDB data and try directly running the latest version and see if it still happens
  2. If it still happens - lets organise some live session where I can try and debug this on your machine if possible so we can finally fix this :)

Hi, thank you for the support! I was finally able to get iOS working on the pre-release version 4.0.1.

However, I haven't been able to test whether it resolves the original issue, as I'm now encountering a memory panic in the hub. From the error message, it seems like this might be a known issue in this pre-release version.

Image

Note: Triggering an Appium refresh from the Android device control also causes the memory panic in the hub.

When testing the WebRTC mode on Android devices running Android 9, I tried all three available codecs, but in every case the screen remained black. I also encountered an issue where, if the gads-stream app was already installed on the device, the provider failed to uninstall it and replace it with the WebRTC app—manually uninstalling gads-stream resolved the problem

yunki-cmd avatar May 08 '25 11:05 yunki-cmd

@yunki-cmd yeah, this "panic" had been long known, unrelated to prerelease - it actually happens when disconnecting from the "video" stream because the stream is proxied from the provider through the hub backend and I haven't found the best solution to fix this in the proxy function - it just prints but it doesn't actually create any problem 😅 But in the logs there is no UDID in the request for the android stream, it is a bit weird 🤔

Regarding WebRTC - it's highly experimental, there are devices that do not work properly with any of the 3 codecs using hardware encoding. Maybe for older SDKs I should just force software encoding. I will get back to you on this. Just in case you can send me the browser console logs when opening such a device, there is kind of comprehensive logging related to WebRTC.

Last but not least - I will look into the different stream apps problem, maybe there is something wrong with the logic behind it, good catch!

shamanec avatar May 08 '25 11:05 shamanec

Okay, okay, so it is not exactly an issue of uninstalling/replacing, but more because they use the same port 1991 on the device - so if one of them is already running, the other one won't start. Definitely trying to uninstall both on device provisioning will fix it so maybe I will go with this as a temporary fix. Going forward I wish I could combine both apps into one but I don't know if it is viable, its too complex already :(

shamanec avatar May 08 '25 13:05 shamanec

Should be fixed on v4.0.0

shamanec avatar Jun 14 '25 10:06 shamanec