Xamarin.Forms crashes at startup on macOS 10.9 Mavericks

Created on 11 May 2020  路  7Comments  路  Source: xamarin/Xamarin.Forms

_From @JunielKatarn on Sat, 09 May 2020 10:08:50 GMT_

Steps to Reproduce

Note, This can happen with any app, but Unjammit can be used for this purpose.

  1. Clone repository (branch macos/bootmavericks)
    git clone --branch macos/bootmavericks https://github.com/JunielKatarn/Unjammit.git
  2. Set location to the cloned repo.
  3. msbuild /t:restore
  4. msbuild macOS/
  5. Open the produced Target/AnycPU/Debug/Unjammit.macOS/Unjammit.app in a Mac (or VM) running Mavericks (10.9).

Expected Behavior

The Xamarin.Forms app opens successfully.

Actual Behavior

The Xamarin app crashes with the following error:

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSWindow contentViewController]: unrecognized selector sent to instance 0x6080001f5e00'
terminating with uncaught exception of type NSException
abort() called

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff8887625c __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x00007fff86471e75 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8887912d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x00007fff887d4272 ___forwarding___ + 1010
4   CoreFoundation                      0x00007fff887d3df8 _CF_forwarding_prep_0 + 120
5   Unjammit                            0x00000001079a97f9 xamarin_dyn_objc_msgSend + 217
6   ???                                 0x000000010df882be 0x0 + 4529357502
7   Unjammit                            0x0000000107a952ae mono_jit_runtime_invoke + 1550
8   Unjammit                            0x0000000107bc8dff mono_runtime_try_invoke + 143
9   Unjammit                            0x0000000107bcbd2f mono_runtime_invoke + 95
10  Unjammit                            0x00000001079a6f27 xamarin_invoke_trampoline + 6167
11  Unjammit                            0x00000001079a8479 xamarin_arch_trampoline + 105
12  Unjammit                            0x00000001079a967e xamarin_x86_64_common_trampoline + 118
13  CoreFoundation                      0x00007fff88844e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
14  CoreFoundation                      0x00007fff8873882d _CFXNotificationPost + 2893
15  Foundation                          0x00007fff8f14cdda -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
16  AppKit                              0x00007fff8d41eb69 -[NSApplication _postDidFinishNotification] + 289
17  AppKit                              0x00007fff8d41e89c -[NSApplication _sendFinishLaunchingNotification] + 195
18  AppKit                              0x00007fff8d41b786 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 570
19  AppKit                              0x00007fff8d41b1db -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 242
20  Foundation                          0x00007fff8f16b52a -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
21  Foundation                          0x00007fff8f16b39d _NSAppleEventManagerGenericHandler + 106
22  AE                                  0x00007fff8fea6e1f _Z20aeDispatchAppleEventPK6AEDescPS_jPh + 381
23  AE                                  0x00007fff8fea6c32 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 31
24  AE                                  0x00007fff8fea6b36 aeProcessAppleEvent + 315
25  HIToolbox                           0x00007fff8eab6161 AEProcessAppleEvent + 56
26  AppKit                              0x00007fff8d4170b6 _DPSNextEvent + 1026
27  AppKit                              0x00007fff8d41689b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
28  AppKit                              0x00007fff8d40a99c -[NSApplication run] + 553
29  AppKit                              0x00007fff8d3f5783 NSApplicationMain + 940
30  ???                                 0x000000010fafb5d5 0x0 + 4558140885
31  ???                                 0x000000010fafb3f3 0x0 + 4558140403
32  Unjammit                            0x0000000107a952ae mono_jit_runtime_invoke + 1550
33  Unjammit                            0x0000000107bc73d8 mono_runtime_invoke_checked + 136
34  Unjammit                            0x0000000107bce885 mono_runtime_exec_main_checked + 117
35  Unjammit                            0x00000001079f1f5c mono_jit_exec + 364
36  Unjammit                            0x00000001079f5094 mono_main + 8676
37  Unjammit                            0x00000001079aa00c xamarin_main + 1116
38  Unjammit                            0x00000001079aae44 main + 36
39  libdyld.dylib                       0x00007fff8e7af5fd start + 1
40  ???                                 0x0000000000000001 0x0 + 1

Thread 0 Crashed:: tid_707  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8991d866 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff8cfab35c pthread_kill + 92
2   libsystem_c.dylib               0x00007fff85b05bc6 __abort + 145
3   libsystem_c.dylib               0x00007fff85b05b35 abort + 140
4   libc++abi.dylib                 0x00007fff88608f31 abort_message + 257
5   libc++abi.dylib                 0x00007fff8862e952 default_terminate_handler() + 264
6   libobjc.A.dylib                 0x00007fff8647230d _objc_terminate() + 103
7   libc++abi.dylib                 0x00007fff8862c1d1 std::__terminate(void (*)()) + 8
8   libc++abi.dylib                 0x00007fff8862bc5b __cxa_throw + 124
9   libobjc.A.dylib                 0x00007fff86471fa1 objc_exception_throw + 343
10  ???                             0x000000010799f287 0 + 4422496903
11  ???                             0x000000010799f177 0 + 4422496631
12  ???                             0x00000001079a9829 0 + 4422539305
13  ???                             0x000000010df882be 0 + 4529357502
14  ???                             0x0000000107a952ae 0 + 4423504558
15  ???                             0x0000000107bc8dff 0 + 4424764927
16  ???                             0x0000000107bcbd2f 0 + 4424777007
17  ???                             0x00000001079a6f27 0 + 4422528807
18  ???                             0x00000001079a8479 0 + 4422534265
19  ???                             0x00000001079a967e 0 + 4422538878
20  com.apple.CoreFoundation        0x00007fff88844e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
21  com.apple.CoreFoundation        0x00007fff8873882d _CFXNotificationPost + 2893
22  com.apple.Foundation            0x00007fff8f14cdda -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
23  com.apple.AppKit                0x00007fff8d41eb69 -[NSApplication _postDidFinishNotification] + 289
24  com.apple.AppKit                0x00007fff8d41e89c -[NSApplication _sendFinishLaunchingNotification] + 195
25  com.apple.AppKit                0x00007fff8d41b786 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 570
26  com.apple.AppKit                0x00007fff8d41b1db -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 242
27  com.apple.Foundation            0x00007fff8f16b52a -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
28  com.apple.Foundation            0x00007fff8f16b39d _NSAppleEventManagerGenericHandler + 106
29  com.apple.AE                    0x00007fff8fea6e1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381
30  com.apple.AE                    0x00007fff8fea6c32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
31  com.apple.AE                    0x00007fff8fea6b36 aeProcessAppleEvent + 315
32  com.apple.HIToolbox             0x00007fff8eab6161 AEProcessAppleEvent + 56
33  com.apple.AppKit                0x00007fff8d4170b6 _DPSNextEvent + 1026
34  com.apple.AppKit                0x00007fff8d41689b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
35  com.apple.AppKit                0x00007fff8d40a99c -[NSApplication run] + 553
36  com.apple.AppKit                0x00007fff8d3f5783 NSApplicationMain + 940
37  ???                             0x000000010fafb5d5 0 + 4558140885
38  ???                             0x000000010fafb3f3 0 + 4558140403
39  ???                             0x0000000107a952ae 0 + 4423504558
40  ???                             0x0000000107bc73d8 0 + 4424758232
41  ???                             0x0000000107bce885 0 + 4424788101
42  ???                             0x00000001079f1f5c 0 + 4422836060
43  ???                             0x00000001079f5094 0 + 4422848660
44  ???                             0x00000001079aa00c 0 + 4422541324
45  ???                             0x00000001079aae44 0 + 4422544964
46  libdyld.dylib                   0x00007fff8e7af5fd start + 1

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib          0x00007fff8991e662 kevent64 + 10
1   libdispatch.dylib               0x00007fff92d41421 _dispatch_mgr_invoke + 239
2   libdispatch.dylib               0x00007fff92d41136 _dispatch_mgr_thread + 52

Thread 2:
0   libsystem_kernel.dylib          0x00007fff8991de6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff8cfabf08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff8cfaefb9 start_wqthread + 13

Thread 3:
0   libsystem_kernel.dylib          0x00007fff8991de6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff8cfabf08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff8cfaefb9 start_wqthread + 13

Thread 4:: SGen worker
0   libsystem_kernel.dylib          0x00007fff8991d716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff8cfacc3b _pthread_cond_wait + 727
2   ???                             0x0000000107c91561 0 + 4425586017
3   libsystem_pthread.dylib         0x00007fff8cfaa899 _pthread_body + 138
4   libsystem_pthread.dylib         0x00007fff8cfaa72a _pthread_start + 137
5   libsystem_pthread.dylib         0x00007fff8cfaefc9 thread_start + 13

Thread 5:: Finalizer
0   libsystem_kernel.dylib          0x00007fff89919a56 semaphore_wait_trap + 10
1   ???                             0x0000000107b4b0df 0 + 4424249567
2   ???                             0x0000000107c217f3 0 + 4425127923
3   ???                             0x0000000107c21637 0 + 4425127479
4   libsystem_pthread.dylib         0x00007fff8cfaa899 _pthread_body + 138
5   libsystem_pthread.dylib         0x00007fff8cfaa72a _pthread_start + 137
6   libsystem_pthread.dylib         0x00007fff8cfaefc9 thread_start + 13

Thread 6:
0   libsystem_kernel.dylib          0x00007fff8991de6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff8cfabf08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff8cfaefb9 start_wqthread + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff77089310  rcx: 0x00007fff5828e4b8  rdx: 0x0000000000000000
  rdi: 0x0000000000000707  rsi: 0x0000000000000006  rbp: 0x00007fff5828e4e0  rsp: 0x00007fff5828e4b8
   r8: 0x0000000000000000   r9: 0x0000000000989680  r10: 0x0000000008000000  r11: 0x0000000000000206
  r12: 0x00007fff5828e670  r13: 0x0000600000131e98  r14: 0x0000000000000006  r15: 0x00007fff5828e550
  rip: 0x00007fff8991d866  rfl: 0x0000000000000206  cr2: 0x00007fff85ad951c

Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133

image

Environment

Runtime

  • OS: macOS 10.9 Mavericks

Development

  • OS: macOS 10.15 Mojave
=== Visual Studio Community 2019 for Mac ===

Version 8.5.5 (build 7)
Installation UUID: e68e0599-8de0-47dc-9825-8a269b3f818c
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.14.1.39 (d16-5 / 30e8706b4)

    Package version: 608000123

=== Mono Framework MDK ===

Runtime:
    Mono 6.8.0.123 (2019-10/1d0d939dc30) (64-bit)
    Package version: 608000123

=== Roslyn (Language Service) ===

3.5.0-beta4-20125-04+1baa0b3063238ed752ad1f0368b1df6b6901373e

=== NuGet ===

Version: 5.4.0.6315

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.200/Sdks
SDK Versions:
    3.1.200
    3.1.102
    3.1.101
    3.1.100
    3.0.101
    3.0.100
    2.1.701
    2.1.700
    2.1.505
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    3.1.2
    3.1.1
    3.1.0
    3.0.1
    3.0.0
    2.1.17
    2.1.16
    2.1.15
    2.1.14
    2.1.13
    2.1.12
    2.1.11
    2.1.9

=== Xamarin.Profiler ===

Version: 1.6.12.26
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.4.1 (16137)
Build 11E503a

=== Xamarin.Mac ===

Version: 6.16.0.13 (Visual Studio Community)
Hash: b75deaf82
Branch: d16-5-xcode11.4
Build date: 2020-04-01 21:33:18-0400

=== Xamarin.iOS ===

Version: 13.16.0.13 (Visual Studio Community)
Hash: b75deaf82
Branch: d16-5-xcode11.4
Build date: 2020-04-01 21:33:19-0400

=== Xamarin.Android ===

Version: 10.2.0.100 (Visual Studio Community)
Commit: xamarin-android/d16-5/988c811
Android SDK: /Users/julio/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.6
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: c0c5c78
Java.Interop: xamarin/java.interop/d16-5@fc18c54
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.28.0@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/julio/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.5.0.39
Hash: 6fb4c79
Branch: remotes/origin/d16-5
Build date: 2020-04-29 20:09:00 UTC

=== Android Device Manager ===

Version: 16.5.0.73
Hash: dff2f03
Branch: remotes/origin/d16-5
Build date: 2020-04-29 20:09:20 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Xamarin Designer ===

Version: 16.5.0.471
Hash: 35aa4889d
Branch: remotes/origin/d16-5
Build date: 2020-02-25 00:52:08 UTC

=== Build Information ===

Release ID: 805050007
Git revision: f7b7ac4291b7712b5e02dd65d45685346f321ded
Build date: 2020-04-30 11:54:56-04
Build branch: release-8.5
Xamarin extensions: f7b7ac4291b7712b5e02dd65d45685346f321ded

=== Operating System ===

Mac OS X 10.15.4
Darwin 19.4.0 Darwin Kernel Version 19.4.0
    Wed Mar  4 22:28:40 PST 2020
    root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

Build Logs

msbuild.log

Example Project

https://github.com/JunielKatarn/Unjammit (macos/bootmavericks branch).

Analysis

The error message seems to complain about an unrecognized selector contentViewController.
See https://developer.apple.com/documentation/appkit/nswindow/1419615-contentviewcontroller

Such type of selector seems to be available only on macOS 10.10 and later.
However, the current Xamarin stack should support version 10.9 or higher (see https://docs.microsoft.com/en-us/xamarin/mac/get-started/hello-mac#requirements).

Looking at Xamarin.Forms.Platform.MacOS/FormsApplicationDelegate.cs:

void UpdateMainPage()
{
    if (_application.MainPage == null)
        return;

    var platformRenderer = (PlatformRenderer)MainWindow.ContentViewController;
    MainWindow.ContentViewController = _application.MainPage.CreateViewController();
    (platformRenderer?.Platform as IDisposable)?.Dispose();
}

It seems to use contentViewController, even though it's not apparently supported on 10.9.
Is this a know issue?
How can we unblock pre-10.10 macOS versions to run Xamarin.Forms?

Thanks.

_Copied from original issue xamarin/xamarin-macios#8556_

high macOS unverified bug

Most helpful comment

However, I'll note that Xamarin.Mac supported OSs are not necessarily the same as Xamarin.Forms on macOS.

Yup. As I said on gitter, I think it'd be useful if the docs pointed out a minimum supported XF macOS version. I've filed https://github.com/MicrosoftDocs/xamarin-docs/issues/2819 for that.

All 7 comments

_From @chamons on Mon, 11 May 2020 14:17:56 GMT_

Moving this over to Xamarin.Forms for consideration.

Such type of selector seems to be available only on macOS 10.10 and later.
However, the current Xamarin stack should support version 10.9 or higher (see https://docs.microsoft.com/en-us/xamarin/mac/get-started/hello-mac#requirements).

However, I'll note that Xamarin.Mac supported OSs are not necessarily the same as Xamarin.Forms on macOS.

Seems to be the same or related with https://github.com/xamarin/Xamarin.Forms/issues/10635

However, I'll note that Xamarin.Mac supported OSs are not necessarily the same as Xamarin.Forms on macOS.

Yup. As I said on gitter, I think it'd be useful if the docs pointed out a minimum supported XF macOS version. I've filed https://github.com/MicrosoftDocs/xamarin-docs/issues/2819 for that.

Quickly looked into this. Although it's easy to swap out the actual cause of this I'm wondering if we go into some kind of rabbit hole. Instead of setting the ContentViewController you need to set ContentView, but I'm wondering if everything from there is prepared from that to happen.

Seeing that Maverick is unsupported for ~3 years now I would opt for just specifying a minimum version for Forms and work from there.

Didn't actually get to verify any of this since I don't have access to a machine with an older version

Instead of setting the ContentViewController you need to set ContentView, but I'm wondering if everything from there is prepared from that to happen.

I'll try that in my application and see how it goes.

It would be awesome if XF/macOS could support the same version range as Xamarin.Mac.

FWIW; according to https://github.com/MicrosoftDocs/xamarin-docs/issues/2819, the minimum supported macOS version for XamForms is considered to be 10.13, which would render this issue moot.

Yep, please use 10.13. Thanks!

Was this page helpful?
0 / 5 - 0 ratings