calabash / run_loop

The bridge between Calabash iOS and Xcode command-line tools like instruments and simctl.
Other
32 stars 41 forks source link

Timed out waiting for UIAutomation run-loop Error while writing to fifo. #368

Closed fancychimp closed 5 years ago

fancychimp commented 8 years ago

We are seeing the following error semi-frequently, yet intermittently

Unable to start. Make sure you've set APP_BUNDLE_PATH to a build supported by this simulator        version
  Background:                            # features/test.feature:4
  Calabash::Cucumber::Launcher::StartError: 

  "Timed out waiting for UIAutomation run-loop Error while writing to fifo.   RunLoop::Fifo::NoReaderConfiguredError.

  Logfile: /Users/app_name/.run-loop/results/2016-01-15_09-06-50/run_loop.out

  2016-01-15 09:06:52.021 instruments[66104:30970590] Failed to start Instruments daemon on     'Automation iPhone (9.1)' (Could not connect to the device.)
  Instruments Usage Error : Specified target process is invalid: com.Appname.iPhoneEnterprise

< EDIT: the gem list was not necessary >

I can resolve this error by uninstalling and reinstalling our app, but am not sure the exact root of the issue. Please let me know if I can provide any further information.

jmoody commented 8 years ago

com.Appname.iPhoneEnterprise

Is it possible that sometimes your app is signed with a distribution profile? Calabash only works with developer profiles.

We're not running on a simulator, so the information provided by this error is odd.

Yeah. It is weird. Pull requests welcome.

I can resolve this error by uninstalling and reinstalling our app, but am not sure the exact root of the issue.

Neither are we. We also struggle with this problem locally after updating the iOS version on our test devices. My strategy/checklist can be found in the Hot Topics on the wiki: FIFO.

One thing that seems to work is to attach the problem device to another machine and open Xcode.

fancychimp commented 8 years ago

Do you still experience this issue on calabash-cucumber 0.17.1?

fancychimp commented 8 years ago

This issue persists daily for us on 0.17.1. We're looking into possible solutions.

Edge-Man commented 8 years ago

I'm seeing this as well with 0.17.1. going to upgrade to the latest to see if that fixes the issue....

jmoody commented 8 years ago

I finally got this to pop on an iOS Simulator. This is with the @TeresaP patch for 2.0.10.pre1.

I have no steps to reproduce (yet). My CoreSimulator environment looks like it is in a good shape (no duplicate CoreSimulatorService processes).

  Calabash::Cucumber::LaunchError: 

  "Timed out waiting for UIAutomation run-loop Error while writing to fifo. RunLoop::Fifo::NoReaderConfiguredError.

  Logfile: /Users/moody/.run-loop/results/2016-03-21_12-12-50/run_loop.out

          2016-03-21 12:12:56.439 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.capabilities"; channel canceled <DTXChannel: 0x7f8b04e18610>
  2016-03-21 12:12:56.439 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.device.xpccontrol"; channel canceled <DTXChannel: 0x7f8b04e13e50>
  2016-03-21 12:12:56.439 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.deviceinfo"; channel canceled <DTXChannel: 0x7f8b04e188e0>
  2016-03-21 12:12:56.439 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.processcontrol"; channel canceled <DTXChannel: 0x7f8b04e19460>
  2016-03-21 12:12:56.440 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.processcontrol.posixspawn"; channel canceled <DTXChannel: 0x7f8b04e19f10>
  2016-03-21 12:12:56.440 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.mobilenotifications"; channel canceled <DTXChannel: 0x7f8b04e1a160>
  2016-03-21 12:12:56.440 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.device.applictionListing"; channel canceled <DTXChannel: 0x7f8b0594d7e0>
  2016-03-21 12:12:56.440 instruments[42906:22555513] Connection peer refused channel request for "com.apple.dt.Xcode.WatchProcessControl"; channel canceled <DTXChannel: 0x7f8b04f31f40>
  2016-03-21 12:12:56.440 instruments[42906:22555513] Connection peer refused channel request for "com.apple.instruments.server.services.wireless"; channel canceled <DTXChannel: 0x7f8b04e1abb0>
  2016-03-21 12:12:56.442 instruments[42906:22555510] WebKit Threading Violation - initial use of WebKit from a secondary thread.
  Instruments Usage Error : Specified target process is invalid: sh.calaba.LPTestTarget
  instruments, version 7.2.1 (59503)
  usage: instruments [-t template] [-D document] [-l timeLimit] [-i #] [-w device] [[-p pid] | [application [-e variable value] [argument ...]]]
jmoody commented 8 years ago

@TheChell

Can you confirm that your app is not signed with an Enterprise or Distribution certificate? It must be signed with a Developer certificate.

jmoody commented 8 years ago

@TeresaP Wacky. I just discovered a very interesting edge case where run-loop thinks the app is installed on a simulator, but it is not. This might be causing this FIFO problem on simulators.

fancychimp commented 8 years ago

@jmoody

Yes, our app is signed with a Developer certificate. The edge case you mention above is exactly what we're seeing as well. The app is not installed on a simulator, but the error indicates it thinks it is.

TeresaP commented 8 years ago

Oh interesting, @jmoody. Good catch!

jmoody commented 8 years ago

@TheChell

edge case

There is a misunderstanding.

In your report, you see:

Unable to start. Make sure you've set APP_BUNDLE_PATH to a build supported by this simulator

That error message was fixed by: https://github.com/calabash/calabash-ios/pull/1006

The edge case I mentioned today appears when targeting iOS Simulators only. Since you are running on devices, this does not apply to your situation.

When we see:

Specified target process is invalid: com.Appname.iPhoneEnterprise

it means that the:

  1. app is not installed on the device
  2. the bundle identifier is incorrect
  3. app is signed with a non-Developer cert
  4. the device does not have UIAutomation enabled
  5. the debugging symbols have not been copied from the device
  6. the device is not enabled for development and/or the device is a bad state that requires a device restart.

4, 5, and 6 usually happen after an iOS update.

This is not limited to 1 device, so I've ruled out device weirdness.

I would not rule out device weirdness.

I can resolve this error by uninstalling and reinstalling our app,

This is why I think your app is signed with a non-Developer cert. How are you deploying the app to the device?

jmoody commented 8 years ago

BTW, I really appreciate your patience. This kind of problem on devices is really frustrating. It happens to me all the time after updating iOS versions - especially when I am testing betas.

If you want to convince yourself that this is a problem with Calabash and not instruments or the device, you can follow the steps in this comment.

When the problem occurs, don't reinstall the app, try following the steps in that issue comment.

jmoody commented 8 years ago

Today I discussed the possibility of building some tooling with @john7doe to detect the cases where the device is in a bad state.

1. Xcode cannot copy debugging symbols (not in the waiting-to-copy state)
2. Device iOS version and active Xcode version are incompatible 
3. Any other bad state.

Number 2. we can implement from ruby: Perform an active Xcode vs. iOS version of device check and fail fast #424

1 and 3 require external tools.

I tried:

$ xcrun xcdevice --usb wait 5 <udid>
$ idevice_id -list
$ ideviceinfo --udid <udid>
$ xcrun instruments -s devices

These all reported that the device was available for case 2.

This will not be fixed for 2.1.0, but the FIFO issue for simulators will be fixed with:

ATTN: @krukow @sapieneptus

jmoody commented 8 years ago

Possibly fixed by Restore UIALogger flushing and ensure variables are substituted properly. #430