When creating a new Appium driver and navigating to a certain URL, 1 out of 2 test runs fails in my environment if a new simulator has to be started. I am using Appium 1.6.1 beta 1 with xcuitest automation on an iOS 10 simulator (MacOS Sierra).
From the log output it seems that the RemoteDebugger receives web site URLs during page change events even though these URLs are not open in the browser (i.e. there is only a single browser tab open). It seems that these URLs are always search engines like https://www.yahoo.com/, https://www.bing.com/ or https://www.google.com so probably Safari does some sort of requests to these search engines when the browser is opened up.
Subsequently a "_rpc_applicationDisconnected" message is received so that the connection to the existing browser tab is closed. Finally the test execution hangs in the call "Sending '_rpc_forwardSocketData:..." where it tries to verify if the page is ready - until the connection times out.
The log output is slightly different each time I execute my test, so there might be some timing issues involved.
Log output:
...
2016-11-14 14:02:25,170 [MJSONWP] Calling AppiumDriver.setUrl() with args: ["http://localhost/index.html/","88c97274-7c7b-4dbc-95a2-760c0c43fbf0"]
2016-11-14 14:02:25,171 [debug] [XCUITest] Executing command 'setUrl'
2016-11-14 14:02:25,173 [debug] [iOS] Attempting to set url 'http://localhost/index.html/'
2016-11-14 14:02:25,174 [debug] [RemoteDebugger] Navigating to new URL: http://localhost/index.html/
2016-11-14 14:02:25,174 [debug] [RemoteDebugger] Sending '_rpc_forwardSocketData:' message to remote debugger
2016-11-14 14:02:25,178 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,178 [debug] [RemoteDebugger] Found data handler for response
2016-11-14 14:02:25,179 [debug] [RemoteDebugger] Received data response from socket send: '{}'
2016-11-14 14:02:25,179 [debug] [RemoteDebugger] Original command: setUrl
2016-11-14 14:02:25,180 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,187 [debug] [RemoteDebugger] Receiving data from remote debugger: '{"__argument":{"WIRApplicationIdentifierKey":"PID:1026","WIRListingKey":{"6":{"WIRTitleKey":"Yahoo","WIRTypeKey":"WIRTypeWeb","WIRURLKey":"https://www.yahoo.com/","WIRPageIdentifierKey":6,"WIRConnectionIdentifierKey":"6498242f-9e42-4723-b0fa-fcc74b61ff56"}}},"__selector":"_rpc_applicationSentListing:"}'
2016-11-14 14:02:25,188 [debug] [RemoteDebugger] Page changed: {"6":{"WIRTitleKey":"Yahoo","WIRTypeKey":"WIRTypeWeb","WIRURLKey":"https://www.yahoo.com/","WIRPageIdentifierKey":6,"WIRConnectionIdentifierKey":"6498242f-9e42-4723-b0fa-fcc74b61ff56"}}
2016-11-14 14:02:25,188 [debug] [iOS] Remote debugger notified us of a new page listing: {"appIdKey":"1026","pageArray":[{"id":6,"title":"Yahoo","url":"https://www.yahoo.com/","isKey":true}]}
2016-11-14 14:02:25,188 [debug] [iOS] Checking if page needs to load
2016-11-14 14:02:25,189 [debug] [iOS] Page load needed. Loading.
2016-11-14 14:02:25,189 [debug] [RemoteDebugger] Page loaded, verifying whether ready
2016-11-14 14:02:25,214 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,217 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,223 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,224 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,387 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] Receiving data from remote debugger: '{"__argument":{"WIRRemoteAutomationEnabledKey":false,"WIRIsApplicationActiveKey":1,"WIRIsApplicationReadyKey":true,"WIRApplicationIdentifierKey":"PID:1026","WIRIsApplicationProxyKey":true,"WIRApplicationNameKey":"","WIRApplicationBundleIdentifierKey":"com.apple.WebKit.WebContent","WIRHostApplicationIdentifierKey":"PID:1020"},"__selector":"_rpc_applicationDisconnected:"}'
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] Application 'PID:1026' disconnected. Removing from app dictionary.
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] Current app is PID:1026
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] No longer have app id. Attempting to find new one.
2016-11-14 14:02:25,390 [debug] [RemoteDebugger] Found app id key 'PID:1020' for bundle 'com.apple.mobilesafari'
2016-11-14 14:02:25,390 [debug] [RemoteDebugger] Found separate bundleId 'com.apple.WebKit.WebContent' acting as proxy for 'com.apple.mobilesafari', with app id 'PID:1024'
2016-11-14 14:02:25,390 [debug] [RemoteDebugger] Using proxied app id 'PID:1024'
2016-11-14 14:02:26,185 [debug] [RemoteDebugger] Waiting for frame navigated message...
2016-11-14 14:02:26,689 [debug] [RemoteDebugger] Frame navigated in 0.503 sec from source: timeout
2016-11-14 14:02:26,689 [debug] [RemoteDebugger] Waiting for dom...
2016-11-14 14:02:26,690 [debug] [RemoteDebugger] Page loaded, verifying whether ready
2016-11-14 14:02:26,369 [debug] [RemoteDebugger] Sending javascript command (function (){ return document.readyState; })()
2016-11-14 14:02:26,369 [debug] [RemoteDebugger] Sending '_rpc_forwardSocketData:' message to remote debugger
...