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

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

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

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 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.