Bug 41226 - Implementing INSWindowRestoration causes crash
Summary: Implementing INSWindowRestoration causes crash
Status: CONFIRMED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) (show other bugs)
Version: 2.8.0 (C7)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-05-20 21:09 UTC by Sjoerd van Noort
Modified: 2017-05-05 07:34 UTC (History)
3 users (show)

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


Attachments
complete example implementation that crashes (356.76 KB, application/zip)
2016-05-20 21:09 UTC, Sjoerd van Noort
Details

Description Sjoerd van Noort 2016-05-20 21:09:03 UTC
Created attachment 16060 [details]
complete example implementation that crashes

Implementing INSWindowRestoration causes a crash when performing window restoration.

Unable to locate the block to delegate conversion method for the method WindowRestorationBug.TestWindowController.RestoreWindow's parameter #3. Please file a bug at http://bugzilla.xamarin.com.

Example solution attached. FIrst make sure "close windows the quiting an app" is turned of in General system preferances.

Then run the. Change some window locations, quit and run again


Xamarin.Mac
Version: 2.8.0.318
Comment 1 Chris Hamons 2016-05-20 21:11:41 UTC
Rolf - That looks like an exception in the Runtime.cs (in your neighborhood). Bounce back to me if I'm wrong.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2016-05-26 12:25:40 UTC
I can reproduce.

This happens because at runtime we need access to the BlockProxy attribute for the RestoreWindow's completionHandler, but that information is not present in the assembly because the method is a required static member (the attribute can be found for required instance members because they're on the IProtocol interface, and for optional members because they're in the Protocol_Extensions class, but for *required static* members, we don't generate anything).

Unfortunately I'm not quite sure where to add the attribute so that it's available at runtime.

Ideas:

a) Add required static members to the Protocol_Extensions class.
b) Add an attribute somewhere (assembly-level?) that can map delegate to blockproxy: [assembly: BlockProxy (target: typeof (NSWindowCompletionHandler), typeof (ObjCRuntime.Trampolines.NIDNSWindowCompletionHandler))]

At least b) would require some linker help though, so that those attributes aren't preserved unless needed.

I'll have to think a bit about this.

Note You need to log in before you can comment on or make changes to this bug.