Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing target for given targetId - silent error causes high rate of failures on Appium 1.17.x through 1.18.3 #14867

Closed
raolaks opened this issue Nov 5, 2020 · 8 comments
Labels
Mobile Safari related to mobile Safari driver

Comments

@raolaks
Copy link

raolaks commented Nov 5, 2020

The problem

We have been lately seeing high rate of failures (18%) on iOS 13 using Appium 1.17.1 and iOS 14 using Appium 1.18.3
The test suites have a 100% success on iOS 12.x running against Appium 1.9.1.

This is particularly difficult as it results in a falsely reported passing test when this am internal failure occurs.

On all of the failed tests, Appium logs report:
Encountered internal error running command: Missing target for given targetId

Environment

  • Appium version (or git revision) that exhibits the issue: 1.17.1 & 1.18.3
  • Last Appium version that did not exhibit the issue (if applicable): 1.9.1
  • Desktop OS/version used to run Appium:
  • Node.js version (unless using Appium.app|exe):
  • Npm or Yarn package manager:
  • Mobile platform/version under test: iOS 13 & iOS 14
  • Real device or emulator/simulator: EmuSim
  • Appium CLI or Appium.app|exe: Appium.exe

Details

We have a customer who runs significantly high volume (close to 1 million) of tests and reporting this.
This is preventing them from moving to iOS 13 or 14 as the issue exists on all appium versions 1.17.1 through 1.18.3

Link to Appium logs

https://gist.github.com/raolaks/e2197c91e4e453f357fdaf87ce3a543b
(Contains 1.9.1/ 1.17.1/ 1.18.3 failures)

@KazuCocoa
Copy link
Member

It seems Web inspector (Safari) returns the message. https://github.com/WebKit/webkit/search?q=Missing+target+for+given+targetId

2020-09-29 20:56:15:812 - [debug] [BaseDriver] Waiting up to 5000 ms for condition
2020-09-29 20:56:15:812 - [debug] [RemoteDebugger] Executing atom 'find_element'
2020-09-29 20:56:15:813 - [debug] [RemoteDebugger] Executing 'find_element' atom in default context
2020-09-29 20:56:15:813 - [debug] [RemoteDebugger] Sending javascript command: '(function(){return function(){var k=this;functi...'
2020-09-29 20:56:15:814 - [debug] [RemoteDebugger] Sending '_rpc_forwardSocketData:' message to app 'PID:5426', page '1', target 'page-50' (id: 48): 'Runtime.evaluate'
2020-09-29 20:56:15:943 - [debug] [RemoteDebugger] Target updated for app 'PID:5426'. Old target: 'page-50', new target: 'page-54'
2020-09-29 20:56:15:946 - [debug] [RemoteDebugger] Application 'PID:5447' disconnected. Removing from app dictionary.
2020-09-29 20:56:15:946 - [debug] [RemoteDebugger] Current app is 'PID:5426'
2020-09-29 20:56:15:946 - [debug] [RemoteDebugger] Target destroyed for app 'PID:5426': page-50
2020-09-29 20:56:15:947 - [debug] [RemoteDebugger] Found provisional target for app 'PID:5426'. Old target: 'page-50', new target: 'page-54'. Updating
2020-09-29 20:56:15:969 - [debug] [RemoteDebugger] Handling message (id: '49')
2020-09-29 20:56:15:969 - [debug] [RemoteDebugger] Sending to Web Inspector took 156ms
2020-09-29 20:56:15:971 - [debug] [XCUITest] Error received while executing atom: Missing target for given targetId

You probably only can do tweaking the find_element rule.
e.g. use XPath or css selector.

@KazuCocoa KazuCocoa added the Mobile Safari related to mobile Safari driver label Nov 6, 2020
@raolaks raolaks changed the title Missing target for given targetId - silent error causes high rate of failures with on Appium 1.17.x through 1.18.3 Missing target for given targetId - silent error causes high rate of failures on Appium 1.17.x through 1.18.3 Nov 6, 2020
@KazuCocoa
Copy link
Member

Dug a bit further. Web Inspector said the target id was changed, so Appium also changed the target. But could this be not true? Then, the updated id by Web Inspector was wrong.

https://github.com/appium/appium-remote-debugger/blob/72794616d1498fc45a01864b8e7d043df63f0fd2/lib/rpc/rpc-client.js#L331-L342

https://github.com/appium/appium-remote-debugger/blob/72794616d1498fc45a01864b8e7d043df63f0fd2/lib/rpc/rpc-client.js#L344-L368


Do you have a chance to share the log with safariLogAllCommunication: true? @raolaks

@raolaks
Copy link
Author

raolaks commented Nov 9, 2020

@KazuCocoa Working on it. I'll attach that here shortly.

@raolaks
Copy link
Author

raolaks commented Nov 13, 2020

@KazuCocoa Here are a few logs with SafariLogAllCommunication flag set
https://gist.github.com/raolaks/48575027ab31ab87b118e762af719049

@dpgraham
Copy link
Contributor

Definitely looks like a race condition (what @KazuCocoa is saying). It's sending the command to act on target 50; the target is changing from 50 to 54; the command operates on target 50 (which is stale)

@dpgraham
Copy link
Contributor

I put in a pull request to fix this. I'm confident that it will work but I haven't been able to reproduce this issue (therefore can't properly test it). I'm going to see about reproducing.

@KazuCocoa
Copy link
Member

Oh, thanks! > PR

@KazuCocoa
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile Safari related to mobile Safari driver
Projects
None yet
Development

No branches or pull requests

3 participants