Bug 23540 - WidgetPerformUpdate is never called in Today Widget
Summary: WidgetPerformUpdate is never called in Today Widget
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.0.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: (C7)
Assignee: Sebastien Pouliot
Depends on:
Reported: 2014-10-01 20:47 UTC by Mike Bluestein
Modified: 2016-01-29 00:58 UTC (History)
8 users (show)

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

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mike Bluestein 2014-10-01 20:47:15 UTC
The WidgetPerformUpdate method is never called in an iOS 8 today widget. An example of this can be seen in the sample app here:

Comment 1 Sebastien Pouliot 2014-10-02 12:00:52 UTC
You're implementing an (optional) method to conform to a protocol (NCWidgetProviding).

Right now the ObjC side is unaware of your method, i.e. it's not registered.


    [Export ("widgetPerformUpdateWithCompletionHandler:")]

to the `WidgetPerformUpdate` should fix that (i.e. if it's registered it will be called).

note: unlike non-protocol methods this is _not_ an override (so there's no base method with the required [Export]).
Comment 2 Sebastien Pouliot 2014-10-02 15:29:33 UTC
It's called - but it seems to crash before reaching managed code

Oct  2 15:26:52 Mars EvolveCountdownWidget[1169] <Error>: 	4   com.xamarin.ExtensionsDemo.EvolveCountdownWidget 0x001f7610 get_delegate_for_block_parameter + 220
Oct  2 15:26:52 Mars EvolveCountdownWidget[1169] <Error>: 	5   com.xamarin.ExtensionsDemo.EvolveCountdownWidget 0x0013cda7 native_to_managed_trampoline_6 + 210
Oct  2 15:26:52 Mars EvolveCountdownWidget[1169] <Error>: 	6   com.xamarin.ExtensionsDemo.EvolveCountdownWidget 0x0013d4fd -[EvolveCountdownViewController widgetPerformUpdateWithCompletionHandler:] + 80
Comment 3 Sebastien Pouliot 2014-10-03 10:38:31 UTC
Looks like we're missing some code. Marking that [Export] as [Abstract] (which is not correct) works.
Comment 5 Christer Nordvik 2014-10-04 15:22:42 UTC
Ok, so the worksaround so far is to write: 
[Abstract ("widgetPerformUpdateWithCompletionHandler:")]?

What I think is weird is that "ViewDidLoad" is called every time the widget is displayed. Is this correct behavior? That's what makes the Today widget in the sample work while I would have expected ViewDidLoad only being called once on initialization. I haven't had a chance to test the same in XCode yet, will try that on Monday.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2014-10-07 10:45:08 UTC

monotouch/master: f5e5752021e76f24070f81cd76dbb15db36b19e5

The ViewDidLoad issue might be because Apple aggressively kills extensions when they're no longer needed (or it could also be due to this bug, which crashes the extension).
Comment 7 Rolf Bjarne Kvinge [MSFT] 2014-10-07 11:06:45 UTC
This fix will be included in Xamarin.iOS 8.4 (early November).
Comment 8 Christer Nordvik 2014-10-09 17:33:29 UTC

Any chance of getting a build with this fix so I can use it while developing? Or is it part of the alpha build in the near future?
Comment 13 Sebastien Pouliot 2014-11-04 16:47:52 UTC
linker support added in master / f9866ecd0ecab9d9e1788e148004dcbb9d70fea2

note: XI 8.4 was for iOS 8.1 only, all fixes (in master) will be part of XI 8.6.
Comment 14 Rolf Bjarne Kvinge [MSFT] 2014-11-05 03:51:29 UTC
Closing wrt comment #13.
Comment 15 Sebastien Pouliot 2016-01-29 00:58:38 UTC
Updated in maccore/master 52186b755230172f97c6793da167875d6a7041ff

The linker support was updated (in C7) to mark only what's required (and not include code that is not needed at runtime).

QA: please re-test the mentioned sample on devices, thanks!