Bug 44606 - [WatchOS] Unreliable connection to the device
Summary: [WatchOS] Unreliable connection to the device
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger ()
Version: XI 10.0 (iOS10)
Hardware: Macintosh Mac OS
: --- minor
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-09-22 03:15 UTC by Shay
Modified: 2017-08-07 15:17 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Log files (491.99 KB, application/zip)
2016-09-22 03:15 UTC, Shay
Details
Deployment and Application output logs (12.62 KB, application/zip)
2016-09-25 04:31 UTC, Shay
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 44606 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Shay 2016-09-22 03:15:05 UTC
Created attachment 17662 [details]
Log files

Similar to BugID 41554 - debugger fails to connect with app.
Steps to recreate:
1. Create a default iOS project.
2. Add the default Watch OS project (Target 10, WatchOS 3).
3. Set provision. Compile and deploy.

Issues:
1. There is a compilation error (see 44601). Disabling incremental build solves this and app compiles and deploys both to phone and watch.

2. However, the debugger never manages to connect to the app.

Following 41554 - 
Phone and watch are on the same network.
Phone app is set for Wifi debugging.
Watch is charging.
Launchd mlaunch-verbosity and recorded the logs (attached).

FYI - no problem uploading/debugging apps using Xcode.
Comment 1 Shay 2016-09-22 03:16:26 UTC
Forgot to mention - latest Xamarin and Xcode. Both computer and watch booted to make sure it's not a random thing.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2016-09-22 05:32:17 UTC
Thanks for getting the logs, but they're unusually unhelpful.

Does the app actually launch on the watch (not just showing a spinning wheel)? If not, does it launch if you tap on it manually?
Comment 3 Shay 2016-09-22 11:50:44 UTC
That was weird. It said deployed, but it didn't actually appear as an icon.
I then manually installed it and now it works. It might be somehow related to the deployment process.
You may close this for now. I will keep you posted if I encounter this behavior again.
Thank you for the quick reply.
Now all I need is to solve a similar issue with my Moto 360 :) (see bug 44602)
Comment 4 Rolf Bjarne Kvinge [MSFT] 2016-09-22 11:53:02 UTC
OK, I'll close it.

If it happens again, please attach the output in the deployment pad as well.
Comment 5 Shay 2016-09-25 04:31:52 UTC
Created attachment 17729 [details]
Deployment and Application output logs
Comment 6 Shay 2016-09-25 04:33:11 UTC
Sorry. I've experienced the problem again.
Seems to be somehow related to whether the app has been previously installed or not (I think). Not consistent. Sometimes manage to connect, sometime doesn't.
I've attached the recent logs during a run in which it wasn't able to connect.
Comment 7 Rolf Bjarne Kvinge [MSFT] 2016-09-26 08:24:02 UTC
@Shay, it's a known issue that the connection to the watch device is inconsistent, sometimes it works, sometimes it doesn't. We're investigating it, but still not sure if it's Apple's fault or ours.

Anyways thanks for the logs. I'll keep this bug open and update when we improve things.
Comment 8 Shay 2016-09-26 22:40:21 UTC
Rolf, I was just trying out a project someone gave me as an example (https://bugzilla.xamarin.com/show_bug.cgi?id=44526), and I experienced a slightly different (but related) error message from the debugger (Connection Refused - see last line).

I couldn't find any additional information online about this error message. Can you provide more details on which conditions lead to "Connection refused" by the debugger?


---------

Using Xcode 8.0 found in /Applications/Xcode.app/Contents/Developer
2016-09-26 18:32:54.541 mlaunch[18670:2081869] Xamarin.Hosting: Xamarin.Hosting
2016-09-26 18:32:54.542 mlaunch[18670:2081869] Xamarin.Hosting:     Xcode: /Applications/Xcode.app
2016-09-26 18:32:54.547 mlaunch[18670:2081869] Xamarin.Hosting:     Xcode Version: 8.0
2016-09-26 18:32:54.547 mlaunch[18670:2081869] Xamarin.Hosting:     Verbosity: 10
2016-09-26 18:32:54.558 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation
2016-09-26 18:32:54.562 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTiPhoneSimulatorRemoteClient.framework/DVTiPhoneSimulatorRemoteClient
2016-09-26 18:32:54.562 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Developer/Library/PrivateFrameworks/CoreSimulator.framework/CoreSimulator
2016-09-26 18:32:54.562 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/DTDeviceKitBase
2016-09-26 18:32:54.568 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/DVTKit
2016-09-26 18:32:54.568 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKit.framework/DTDeviceKit
2016-09-26 18:32:54.569 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTXConnectionServices.framework/DTXConnectionServices
2016-09-26 18:32:54.570 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTSourceControl.framework/DVTSourceControl
2016-09-26 18:32:54.571 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTServices.framework/DVTServices
2016-09-26 18:32:54.572 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTPortal.framework/DVTPortal
2016-09-26 18:32:54.573 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftCore.dylib
2016-09-26 18:32:54.573 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftDarwin.dylib
2016-09-26 18:32:54.573 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftObjectiveC.dylib
2016-09-26 18:32:54.574 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftDispatch.dylib
2016-09-26 18:32:54.574 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftXPC.dylib
2016-09-26 18:32:54.575 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftos.dylib
2016-09-26 18:32:54.575 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftIOKit.dylib
2016-09-26 18:32:54.576 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftCoreGraphics.dylib
2016-09-26 18:32:54.578 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftFoundation.dylib
2016-09-26 18:32:54.580 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftCoreData.dylib
2016-09-26 18:32:54.582 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftCoreImage.dylib
2016-09-26 18:32:54.584 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/libswiftAppKit.dylib
2016-09-26 18:32:54.589 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTDocumentation.framework/DVTDocumentation
2016-09-26 18:32:54.590 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTAnalyticsClient.framework/DVTAnalyticsClient
2016-09-26 18:32:54.592 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTAnalytics.framework/DVTAnalytics
2016-09-26 18:32:54.594 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/SourceKit.framework/SourceKit
2016-09-26 18:32:54.602 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework/IDEFoundation
2016-09-26 18:32:54.641 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTGraphKit.framework/DTGraphKit
2016-09-26 18:32:54.641 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTDeveloperModeHelper.framework/DVTDeveloperModeHelper
2016-09-26 18:32:54.644 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DADocSetAccess.framework/DADocSetAccess
2016-09-26 18:32:54.647 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DADocSetManagement.framework/DADocSetManagement
2016-09-26 18:32:54.648 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTProducts.framework/DVTProducts
2016-09-26 18:32:54.664 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/IDEKit
2016-09-26 18:32:54.667 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IBFoundation.framework/IBFoundation
2016-09-26 18:32:54.669 mlaunch[18670:2081869] Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IBAutolayoutFoundation.framework/IBAutolayoutFoundation
2016-09-26 18:32:54.928 mlaunch[18670:2081869] Xamarin.Hosting: Loaded Xcode plugins successfully.
2016-09-26 18:32:54.956 mlaunch[18670:2081900] Xamarin.Hosting: Device discovery started
2016-09-26 18:32:55.205 mlaunch[18670:2081902] Xamarin.Hosting: Device discovery event: Connected
2016-09-26 18:32:55.205 mlaunch[18670:2081898] Xamarin.Hosting: Device discovery event: GizmoPaired
2016-09-26 18:32:55.205 mlaunch[18670:2081898] Xamarin.Hosting: Watch discovery event: GizmoPaired
2016-09-26 18:32:55.209 mlaunch[18670:2081879] Xamarin.Hosting: Device discovery event: Connected
2016-09-26 18:32:56.141 mlaunch[18670:2081900] Xamarin.Hosting: Mounting developer image on 'iPhone5c'
2016-09-26 18:32:56.156 mlaunch[18670:2081900] Xamarin.Hosting: Mounted developer image on 'iPhone5c'
2016-09-26 18:32:58.421 mlaunch[18670:2081901] Xamarin.Hosting: Mounting developer image on 'Shay’s Apple Watch'
2016-09-26 18:32:59.056 mlaunch[18670:2081901] Xamarin.Hosting: Mounted developer image on 'Shay’s Apple Watch'
2016-09-26 18:32:59.206 mlaunch[18670:2081901] Xamarin.Hosting: The paired device for 'iPhone5c' is 'Shay’s Apple Watch'.
2016-09-26 18:32:59.213 mlaunch[18670:2081901] Xamarin.Hosting: Launching com.climbtag2.xfwatch.watchkitapp (with extension com.climbtag2.xfwatch.watchkitapp.watchkitextension) on 'iPhone5c'
2016-09-26 18:32:59.214 mlaunch[18670:2081901] Xamarin.Hosting: Original arguments: -monodevelop-port 10000 -connection-mode usb
2016-09-26 18:32:59.214 mlaunch[18670:2081901] Xamarin.Hosting: Original environment:
2016-09-26 18:32:59.215 mlaunch[18670:2081901] Xamarin.Hosting:     __XAMARIN_DEBUG_PORT__=10000
2016-09-26 18:32:59.245 mlaunch[18670:2081901] Xamarin.Hosting: Listening on 51411...
2016-09-26 18:32:59.580 mlaunch[18670:2081901] Xamarin.Hosting: Updated arguments: -monodevelop-port 51411 -connection-mode usb
2016-09-26 18:32:59.580 mlaunch[18670:2081901] Xamarin.Hosting: Updated environment:
2016-09-26 18:32:59.580 mlaunch[18670:2081901] Xamarin.Hosting:     __XAMARIN_DEBUG_PORT__=51411
2016-09-26 18:32:59.580 mlaunch[18670:2081901] Xamarin.Hosting:     __XAMARIN_DEBUG_HOSTS__=192.168.0.4
2016-09-26 18:32:59.580 mlaunch[18670:2081901] Xamarin.Hosting:     __XAMARIN_DEBUG_MODE__=http
2016-09-26 18:32:59.581 mlaunch[18670:2081901] Xamarin.Hosting: Starting instruments server on 'Shay’s Apple Watch'
2016-09-26 18:33:01.537 mlaunch[18670:2081915] Xamarin.Hosting: Started instruments server on 'Shay’s Apple Watch'
2016-09-26 18:33:02.088 mlaunch[18670:2081915] Xamarin.Hosting: Requesting xpc observation on: 'Shay’s Apple Watch' for 'com.climbtag2.xfwatch.watchkitapp.watchkitextension'
	Arguments: (     "-monodevelop-port",     51411,     "-connection-mode",     usb )
	Environment variables: {     "__XAMARIN_DEBUG_HOSTS__" = "192.168.0.4";     "__XAMARIN_DEBUG_MODE__" = http;     "__XAMARIN_DEBUG_PORT__" = 51411; }
	Options: {     DisableMemoryLimits = 0;     EnableExtension = 1; }
	Message: < DTXMessage 0x7ff31e8598b0 : i0.0 c0 dispatch:[observeServicesWithIdentifier:"com.climbtag2.xfwatch.watchkitapp.watchkitextension" requestingProcess:[0] environment:< NSDictionary 0x7ff31e85a740 | 3 key/value pairs> arguments:< NSArray 0x7ff31e859760 | 4 objects > options:< NSDictionary 0x7ff31e85a7b0 | 2 key/value pairs>] >
2016-09-26 18:33:02.259 mlaunch[18670:2081879] Xamarin.Hosting: Got observe answer: < DTXMessage 0x7ff31e8591b0 : i5.1 c1 >
2016-09-26 18:33:02.377 mlaunch[18670:2081916] Xamarin.Hosting: Requesting launch on 'iPhone5c' for 'com.climbtag2.xfwatch':
	Options: {
	}
	Message: < DTXMessage 0x7ff31ead9ed0 : i0.0 c0 dispatch:[launchWatchAppForCompanionIdentifier:"com.climbtag2.xfwatch" options:< NSDictionary 0x7ff31eadaf80 | 0 key/value pairs>] >
2016-09-26 18:33:04.139 mlaunch[18670:2081879] Xamarin.Hosting: Got launch answer: < DTXMessage 0x7ff31eac44c0 : i3.1 c1 >
2016-09-26 18:33:04.710 mlaunch[18670:2081881] Xamarin.Hosting: Observed service 'com.climbtag2.xfwatch.watchkitapp.watchkitextension' was launched with pid '422'.
2016-09-26 18:33:04.712 mlaunch[18670:2081879] Xamarin.Hosting: Launched after 1/10 attempt(s).
Launched watch application 'com.climbtag2.xfwatch.watchkitapp' on 'Shay’s Apple Watch' with pid 422
2016-09-26 18:33:04.714 mlaunch[18670:2081881] Xamarin.Hosting: Attaching native debugger on device.
2016-09-26 18:33:04.714 mlaunch[18670:2081915] Xamarin.Hosting: Starting native debugger session on Shay’s Apple Watch
2016-09-26 18:33:05.382 mlaunch[18670:2081915] Xamarin.Hosting: Starting native debugger service
2016-09-26 18:33:05.580 mlaunch[18670:2081915] Xamarin.Hosting: Attaching to pid: 422
2016-09-26 18:33:06.418 mlaunch[18670:2081915] Xamarin.Hosting: Continuing
2016-09-26 18:33:06.418 mlaunch[18670:2081915] Xamarin.Hosting: Attached to app.
Xamarin.WatchOS: Found debug mode http in environment variables
Xamarin.WatchOS: Found port 51411 in environment variables
Xamarin.WatchOS: Found host 192.168.0.4 in environment variables
Xamarin.WatchOS: IDE Port: 51411 Transport: HTTP
2016-09-26 18:33:06.993 mlaunch[18670:2081900] Xamarin.Hosting: 6:33:06 PM 422/1 Got context: http://192.168.0.4:51411/download?pid=422&id=1
2016-09-26 18:33:06.997 mlaunch[18670:2081900] Xamarin.Hosting: 6:33:06 PM 422/1 Could not connect to 10000: Connection refused
Comment 9 Rolf Bjarne Kvinge [MSFT] 2016-09-27 08:17:09 UTC
> Xamarin.Hosting: Original arguments: -monodevelop-port 10000 -connection-mode usb

Make sure WiFi debugging is enabled in the project's options (future versions of Xamarin Studio will enforce this).
Comment 10 Shay 2016-09-27 15:23:50 UTC
WiFi was enabled. I think (*) this was related to the fact that both the phone app and the watch app were set to the same debugging port. You guys might want to disable this option as well (or at least give a warning).

BTW, is there a way to get debugging messages from both phone and watch on the console (i.e., attach to process - https://mkswap.net/m/ios/watchkit/2015/01/11/debug-ios-app-while-watchkitapp-is-running.html) in Xamarin Studio? Right now I'm using the device screen to display debug messages and that's not ideal.
Comment 11 Rolf Bjarne Kvinge [MSFT] 2016-09-29 12:19:21 UTC
(In reply to Shay from comment #10)

> BTW, is there a way to get debugging messages from both phone and watch on
> the console (i.e., attach to process -
> https://mkswap.net/m/ios/watchkit/2015/01/11/debug-ios-app-while-watchkitapp-
> is-running.html) in Xamarin Studio? Right now I'm using the device screen to
> display debug messages and that's not ideal.

It's not exactly what you're asking for, but you can get the device log in a terminal window by executing this:

    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch --logdev --devname "device name"

and then you run that in two terminal windows, one for the phone and one for the watch.