install! triggers: Mach error -308 - (ipc/mig) server died
Hi Johannes,
We're seeing a quite frequent problem when trying to install apps in the simulator and I'm wondering if you've ever encountered it:
We're running the following command to start the simulator and install the app:
# launch the simulator
@device.launch!
@device.wait! {|d| d.state == :booted}
# install the app
@device.install!(@app_path)
Quite often, the install! step fails and we get the following output:
An error was encountered processing the command (domain=NSMachErrorDomain, code=-308):
The operation couldn’t be completed. (Mach error -308 - (ipc/mig) server died)
(StandardError)
I found this thread on the dev forums https://forums.developer.apple.com/message/70514#70514
That lead me to these crash reports: https://gist.github.com/garriguv/d6a35a39ec87e33254917948c130d357
Not super helpful but I've filed a radar.
I've had to add a pretty long sleep before trying to install the app. That reduces the occurrences but it obviously not optimal...
Hey Vincent,
we were not using the install! command of simctl at all, so we never ran into this issue. From a first glance at your crash log and the error message I must admit that I don't have any idea what might be causing this, sorry!
In the crash log I noticed that the path to your Xcode is /Applications/Xcode-8.1.app. I assume it's one of your CI nodes, right? Are your jobs using different versions of Xcode? Is it possible that there are still some processes of the Simulator running from a previous job execution, that got launched by Xcode 8.1 and the next job will be using a different version of Xcode?
We did have that issue in the past when we migrated from 8.0 to 8.1. It ended up throwing different errors. I don't think this is related.
I submitted the radar this morning, I'll see if I hear back from Apple. This is causing us a lot of problems so I'm considering using one of our technical support incidents.
In the meantime, this is the code we're using:
begin
@device.install!(@app_path)
rescue StandardError => e
sleep(5)
@device.install!(@app_path)
end
If you're not using the install! command, how are you installing your app on the simulators?
Sorry I couldn't help here!
I just pushed some changes (7e33c03b347a8c25830575cac6c75fd481e5be88) to master that might help you:
@device.launch
@device.wait(90) {|d| d.state == :booted && d.ready? }
@device.install(@app_path)
The 90 here is not the waiting time, it's the timeout. If you're curious what it does: It checks for a list of (launchd) processes that belong to the Simulator, which are supposed to define some readiness. Similar to what FBSimulatorControl does. ~Right now this will only work for iPhone/iPad Simulators~ should now also work for these, but didn't test properly.
If you're not using the install! command, how are you installing your app on the simulators?
Sorry, I completely missed this question!
We're using pxctest on our CI.
I'm on vacation this week but I'll try the command when I'm back next Monday.
I did see some tweets (from you I believe?) mentioning the technique Facebook uses in xctool. It's really nice that you implemented it. Thank you!
You're welcome - I hope it resolves your issues.
Enjoy your vacation :)!
@plu when should the required_services_for_ready be present? when the simulator is fully booted? I do not see those services at all when my sim is fully booted and running tests
I'm not running simctl, just emulating some of its behavior in my own build script
EDIT: I wasn't running the launchctl in the simulator, just on my mac. oops
@plu , so this commit waits until the following state is finished?
We're seeing the same error mode now on upgrading from Xcode 8.2.x to 8.3.x. I'm presuming that this might be caused by the set of services that are being waited on for the simulator to be considered ready? In the CoreSimulator logs, we're getting errors with:
CoreSimulatorBridge[67683]: Error in registering callback port Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Port is invalid., NSLocalizedDescription=Unable to register pasteboard callback port.}
We're using the suggestion above with the:
timeout = 240 device = SimCtl.device(udid: device_id) device.boot device.wait(timeout) { |d| d.state == :booted && d.ready? }
Any ideas?
Also, I noticed we're using boot versus launch, but I'm not sure if there is something substantially different between the two.