Bug 24027 - [App Extensions] Can't use GetWidgetMarginInsets in a Today Extension
Summary: [App Extensions] Can't use GetWidgetMarginInsets in a Today Extension
Status: CLOSED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: master
Hardware: Macintosh Mac OS
: --- blocker
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-10-23 18:42 UTC by Chris Hardy [MSFT]
Modified: 2015-02-06 08:00 UTC (History)
4 users (show)

Tags:
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:
Status:
CLOSED FIXED

Description Chris Hardy [MSFT] 2014-10-23 18:42:24 UTC
Running a master build of Xamarin.iOS (though not sure if this is the actual problem), when using the following code: 

[Export("widgetMarginInsetsForProposedMarginInsets:")]
public UIEdgeInsets GetWidgetMarginInsets (UIEdgeInsets defaultMarginInsets)
{
	var newInsets = new UIEdgeInsets (defaultMarginInsets.Top, defaultMarginInsets.Left - 50, 
		                defaultMarginInsets.Bottom - 44, defaultMarginInsets.Right);
	return newInsets;
}

causes the following exception on a iPhone 6 device:

https://gist.github.com/chrisntr/2aee70ef0fa48bbd8fde

Haven't been able to run the extension at all on Simulator due to another issue.



Xamarin Studio
Version 5.7 (build 322)
Installation UUID: c396d030-fdb3-403e-b41c-8cf9b3c835dc
Runtime:
	Mono 3.10.0 ((detached/633e444)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000020

Apple Developer Tools
Xcode 6.1 (6604)
Build 6A1052d

Xamarin.Mac
Version: 1.11.1.3 (Business Edition)

Xamarin.Android
Version: 4.99.0.144 (Business Edition)
Android SDK: /Users/chrisntr/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3.3  (API level 10)
		3.0    (API level 11)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

Xamarin.iOS
Version: 8.5.0.14 (Business Edition)
Hash: 71890c1
Branch: 
Build date: 2014-10-22 18:24:23-0400

Build Information
Release ID: 507000322
Git revision: e70496f26ed71a30bb1817f81fb372e573cd2686
Build date: 2014-10-22 10:14:44-04

Operating System
Mac OS X 10.10.0
Darwin ChrisMacBookAir-4.local 14.0.0 Darwin Kernel Version 14.0.0
    Tue Sep 23 23:01:41 PDT 2014
    root:xnu-2782.1.97~6/RELEASE_X86_64 x86_64
Comment 1 Sebastien Pouliot 2014-10-29 10:01:33 UTC
> causes the following exception on a iPhone 6 device:

Only on iPhone 6 ? because it works for me on other devices (using master HEAD).

Any other instructions beside enabling the extension ? and seeing it in Today's screen (57).

note: I still have to add a linker rule, but that does not seem related to your issue (it's for the [Block] on WidgetPerformUpdate complitionHandler, not for GetWidgetMarginInsets).
Comment 6 Chris Hardy [MSFT] 2014-10-29 14:06:00 UTC
It seems that if I turn off linking, I get the following issue:

Unhandled Exception:
ObjCRuntime.RuntimeException: Unable to locate the block to delegate conversion method for the method TodayExtension.TodayViewController.WidgetPerformUpdate's parameter #1. Please file a bug at http://bugzilla.xamarin.com.
at ObjCRuntime.Runtime.GetBlockWrapperCreator (System.Reflection.MethodInfo method, Int32 parameter) [0x001cd] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:402
at ObjCRuntime.Runtime.GetBlockWrapperCreator (IntPtr method, Int32 parameter) [0x00000] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:163
at ObjCRuntime.Runtime.get_block_wrapper_creator (IntPtr method, Int32 parameter) [0x00000] in /Developer/MonoTouch/Source/maccore/runtime/Delegates.generated.cs:106
at (wrapper native-to-managed) ObjCRuntime.Runtime:get_block_wrapper_creator (intptr,int)
Oct 29 12:35:02 Totoro-Phone TodayExtension[259] <Warning>: Unhandled managed exception: Unable to locate the block to delegate conversion method for the method TodayExtension.TodayViewController.WidgetPerformUpdate's parameter #1. Please file a bug at http://bugzilla.xamarin.com. (ObjCRuntime.RuntimeException)
at ObjCRuntime.Runtime.GetBlockWrapperCreator (System.Reflection.MethodInfo method, Int32 parameter) [0x001cd] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:402
at ObjCRuntime.Runtime.GetBlockWrapperCreator (IntPtr method, Int32 parameter) [0x00000] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:163
at ObjCRuntime.Runtime.get_block_wrapper_creator (IntPtr method, Int32 parameter) [0x00000] in /Developer/MonoTouch/Source/maccore/runtime/Delegates.generated.cs:106
at (wrapper native-to-managed) ObjCRuntime.Runtime:get_block_wrapper_creator (intptr,int)

Fixing this will be a good start to see if that also fixes the other issue with Release.
Comment 7 Sebastien Pouliot 2014-10-29 14:12:37 UTC
Ok, that's the issue on my radar - and it applies to WidgetPerformUpdate, i.e. it's unrelated to GetWidgetMarginInsets (where there's no such block).

> It seems that if I turn off linking, I get the following issue:

OTOH it should work, not fail, *without* linking and should fail *with* linking (because it would, likely, be removed). You seem to imply the reverse. 

Testing without linking now...
Comment 9 Sebastien Pouliot 2014-10-29 15:22:14 UTC
> It seems that if I turn off linking, I get the following issue:

Are you sure you turned off linking in the extension ? (not the main app).

I can reproduce, on 64bits, your original issue without linking (not sure if it's 64bits, release or because it's not linked yet). But I do not see how you can hit the condition in comment #6 if the linker is disabled.

Can you try this again and attach the build log (do a clean on the solution first) ?
Comment 11 Rolf Bjarne Kvinge [MSFT] 2014-10-31 15:40:57 UTC
I fixed a Release mode issue today, so this might have been fixed.

If I disable the linker in the test project (for the extension) from comment #2, the extension works fine.
Comment 12 Chris Hardy [MSFT] 2014-11-05 19:47:22 UTC
This seems to be working as expected now!
Comment 13 Udham Singh 2015-02-06 08:00:24 UTC
As per comment 12, I am closing this issue. Thanks!