Bug 41226

Summary: Implementing INSWindowRestoration causes crash
Product: [Desktop] Xamarin.Mac Reporter: Sjoerd van Noort <sjoerd.v.noort>
Component: Library (Xamarin.Mac.dll)Assignee: Rolf Bjarne Kvinge [MSFT] <rolf>
Severity: normal CC: chris.hamons, mono-bugs+monomac, rolf
Priority: Normal    
Version: 2.8.0 (C7)   
Target Milestone: Future Cycle (TBD)   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: complete example implementation that crashes

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

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.


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.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2018-03-16 11:13:53 UTC
c) We can put the BlockProxy type in the ProtocolMember attribute.