Bug 34513

Summary: [watchOS] Complication can be selected; but display never updates
Product: iOS Reporter: CraigD <craig.dunn>
Component: Xamarin.WatchOS.dllAssignee: Rolf Bjarne Kvinge [MSFT] <rolf>
Status: VERIFIED FIXED    
Severity: normal CC: mono-bugs+monotouch, rolf, saurabhd
Priority: ---    
Version: XI 9.3 (xcode 7.1 previews)   
Target Milestone: 10.0.0 (C8)   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description CraigD 2015-10-01 19:55:30 UTC
The code for the sample I'm using is available here:
https://github.com/conceptdev/xamarin-ios-samples/tree/master/WatchComplication

Works:
* Complication appears in lists for selection in (watch face configuration), and can be selected.
* Application log shows "Extension received request to wake up for complication support" periodically.
* Clicking on the complication opens the watch app.
* Complication appears in iPhone simulator's "Watch App" complications list (screenshot in github repo).

Does not work:
* None of the methods in ComplicationController appear to be called.
* In (watch face configuration) it is expected that the `GetPlaceholderTemplate` would be called to show "test" content, but it does not.
* When the watch face is showing, it only ever displays the `BundleDisplayName`, `GetCurrentTimelineEntry` is never called.

I wonder if this is related to #33788 (ExtensionDelegate methods aren't called)?



=== Xamarin Studio ===

Version 5.10 (build 913)
Installation UUID: 81270b48-59a5-4b76-86eb-a908e437fbd4
Runtime:
	Mono 4.0.4 ((detached/d481017)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400040004

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 5.1.6.7 (Business Edition)
Android SDK: /Users/craigdunn/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)

SDK Tools Version: 24.3.4
SDK Platform Tools Version: 22
SDK Build Tools Version: 22.0.1

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.1
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 7.1 (9069)
Build 7B75

=== Xamarin.Mac ===

Version: 2.0.2.111 (Business Edition)

=== Xamarin.iOS ===

Version: 9.3.0.243 (Business Edition)
Hash: 155d35b
Branch: master
Build date: 2015-09-30 18:26:52-0400

=== Build Information ===

Release ID: 510000913
Git revision: d437b9453df0bd08103df76b60a2bb95c3a864a6
Build date: 2015-09-30 16:56:55-04
Xamarin addins: 2c839fd62864efbeb8d02091e4ba3dfde24a099a
Build lane: monodevelop-lion-xcode7.1

=== Operating System ===

Mac OS X 10.10.5
Darwin Craigs-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 1 CraigD 2015-10-29 03:20:37 UTC
Using Preview 2
https://releases.xamarin.com/preview-watchos-2-0-tvos-second-preview/


Additional information - this from a different sample
https://github.com/conceptdev/xamarin-ios-samples/tree/master/Watch8Ball


ObjCRuntime.RuntimeException: Unable to locate the block to delegate conversion method for the method ClockKit.CLKComplicationDataSource.GetPlaceholderTemplate's parameter #2. Please file a bug at http://bugzilla.xamarin.com.
  at ObjCRuntime.Runtime.GetBlockWrapperCreator (System.Reflection.MethodInfo method, Int32 parameter) [0x001cd] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/src/ObjCRuntime/Runtime.cs:604 
  at ObjCRuntime.Runtime.GetBlockWrapperCreator (IntPtr method, Int32 parameter) [0x00000] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/src/ObjCRuntime/Runtime.cs:240 
  at ObjCRuntime.Runtime.get_block_wrapper_creator (IntPtr method, Int32 parameter) [0x00000] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/runtime/Delegates.generated.cs:108 
  at (wrapper native-to-managed) ObjCRuntime.Runtime:get_block_wrapper_creator (intptr,int)
2015-10-29 18:14:25.824 Watch8BallApp.WatchKitExtension[15426:3053584] Unhandled managed exception:
Unable to locate the block to delegate conversion method for the method ClockKit.CLKComplicationDataSource.GetPlaceholderTemplate's parameter #2. Please file a bug at http://bugzilla.xamarin.com. (ObjCRuntime.RuntimeException)
  at ObjCRuntime.Runtime.GetBlockWrapperCreator (System.Reflection.MethodInfo method, Int32 parameter) [0x001cd] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/src/ObjCRuntime/Runtime.cs:604 
  at ObjCRuntime.Runtime.GetBlockWrapperCreator (IntPtr method, Int32 parameter) [0x00000] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/src/ObjCRuntime/Runtime.cs:240 
  at ObjCRuntime.Runtime.get_block_wrapper_creator (IntPtr method, Int32 parameter) [0x00000] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/runtime/Delegates.generated.cs:108 
  at (wrapper native-to-managed) ObjCRuntime.Runtime:get_block_wrapper_creator (intptr,int)
Comment 2 CraigD 2015-10-29 04:47:12 UTC
More info - reproduced in the original sample mentioned with Preview 2 (exception message at the end)
https://github.com/conceptdev/xamarin-ios-samples/tree/master/WatchComplication

Differences from initial bug report:

* the constructor of the ComplicationController constructor is called (this didn't happen previously) 
2015-10-29 19:30:05.821 WatchComplication[16117:3106574] Extension received request to wake up for complication support.
2015-10-29 19:30:06.008 WatchComplication[16117:3106272] Complication ctor

* the ExtensionDelegate lifecycle methods are now called too

NOTE: it does seem strange that the `IntPtr` ctor doesn't get called :(
`public ComplicationController (IntPtr p) : base (p) {}`

--------------
Unable to locate the block to delegate conversion method for the method ClockKit.CLKComplicationDataSource.GetPlaceholderTemplate's parameter #2. Please file a bug at http://bugzilla.xamarin.com. (ObjCRuntime.RuntimeException)
  at ObjCRuntime.Runtime.GetBlockWrapperCreator (System.Reflection.MethodInfo method, Int32 parameter) [0x001cd] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/src/ObjCRuntime/Runtime.cs:604 
  at ObjCRuntime.Runtime.GetBlockWrapperCreator (IntPtr method, Int32 parameter) [0x00000] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/src/ObjCRuntime/Runtime.cs:240 
  at ObjCRuntime.Runtime.get_block_wrapper_creator (IntPtr method, Int32 parameter) [0x00000] in /Users/builder/data/lanes/2128/efb0d4d9/source/maccore/runtime/Delegates.generated.cs:108 
  at (wrapper native-to-managed) ObjCRuntime.Runtime:get_block_wrapper_creator (intptr,int)
Comment 6 CraigD 2016-01-07 01:45:23 UTC
This seems to _partially_ fixed in Preview #4
https://forums.xamarin.com/discussion/57967/tvos-and-watchos-2-0-preview-4-xamarin-studio-with-designer-memory-profiling-support

The behaviour now is:

* GetPlaceholderTemplate is called successfully to choose/populate the complication in the "config" state

* GetCurrentTimelineEntry is called successfully ONCE, the first time the face is displayed, to render the complication.

* GetSupportedTimeTravelDirections calls seem to work, and enable/disable the complication display when timetravel is used.

* GetNextRequestedUpdateDate gets called, BUT after the specified time period, there is a CRASH before GetCurrentTimelineEntry is called again

crash log:
https://gist.github.com/conceptdev/c08c3c6549e05ff6a41d

code still at:
https://github.com/conceptdev/xamarin-ios-samples/tree/master/WatchComplication
Comment 7 Rolf Bjarne Kvinge [MSFT] 2016-01-07 19:07:59 UTC
@Craig, do you know how to make the watch call GetNextRequestedUpdateDate consistently? I managed to do it a few times, but now I can't get the watch to call the method anymore.
Comment 8 CraigD 2016-01-07 19:15:32 UTC
Sorry, I haven't figured this out either. It did seem to be more reliable if I quit both emulators (phone and watch) before starting debugging; rather than trying to run when the emulators were already open. I haven't seen any info via Googling either :-\
Comment 9 Rolf Bjarne Kvinge [MSFT] 2016-08-26 17:20:38 UTC
PR: https://github.com/xamarin/xamarin-macios/pull/685
Comment 10 Rolf Bjarne Kvinge [MSFT] 2016-08-26 17:22:44 UTC
The test case needs this with recent version of XI: https://github.com/conceptdev/xamarin-ios-samples/pull/2
Comment 11 Rolf Bjarne Kvinge [MSFT] 2016-08-26 20:54:58 UTC
PR merged (master): https://github.com/xamarin/xamarin-macios/commit/db04e2435b36113f11a83b3a6a5ef7e3506103d4

I'll try to get it in C8 as well.
Comment 12 Rolf Bjarne Kvinge [MSFT] 2016-08-29 08:13:22 UTC
C8 PR: https://github.com/xamarin/xamarin-macios/pull/696
Comment 13 Rolf Bjarne Kvinge [MSFT] 2016-08-29 13:34:12 UTC
C8 PR merged: https://github.com/xamarin/xamarin-macios/commit/5528ba069b726c7f441826ad96c84905f4898495
Comment 14 Saurabh 2016-09-12 07:37:44 UTC
I have checked this issue with latest Cycle 8 builds (XS 6.1.0.5441 + XI 10.0.0.6) and observed that methods mentioned in ComplicationController called and appears in application output also complication can be selected and updated.

Application Output: https://gist.github.com/saurabh360/6df7104bc5e6e8952223554a5bdba977
http://www.screencast.com/t/ghwZbVYS

Environment Info and details: https://gist.github.com/tajinder360/196a5d9958b92910f40f54f7ee563506