Call PushModalAsync to show a modal page. Close the page. Then do it again. The app will crash.
Modal shows again.
Crash and this shows up in the output...
2019-07-14 09:40:21.008 PushModal.Mac[4644:3412733] *** Assertion failure in -[Xamarin_Forms_Platform_MacOS_PlatformRenderer transitionFromViewController:toViewController:options:completionHandler:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671.50.111/Controllers/NSViewController.m:923
2019-07-14 09:40:21.009 PushModal.Mac[4644:3412733] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'fromViewController.view.superview must not be nil'
...
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_IntPtr_UInt64_IntPtr <0x000ee>
at AppKit.NSViewController:TransitionFromViewController <0x0099a>
at Xamarin.Forms.Platform.MacOS.NSViewControllerExtensions:HandleAsyncAnimation <0x00312>
at Xamarin.Forms.Platform.MacOS.ModalPageTracker:PresentModalAsync <0x00932>
at Xamarin.Forms.Platform.MacOS.ModalPageTracker:PushAsync <0x00262>
at Xamarin.Forms.Platform.MacOS.PlatformNavigation:Xamarin.Forms.INavigation.PushModalAsync <0x00122>
at Xamarin.Forms.Internals.NavigationProxy:OnPushModal <0x001f3>
at NavigationImpl:<>n__1 <0x00082>
at <OnPushModal>d__3:MoveNext <0x00372>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x0020a>
at NavigationImpl:OnPushModal <0x0035a>
at Xamarin.Forms.Internals.NavigationProxy:PushModalAsync <0x* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
I can reproduce the problem. In other platforms it works without problems but in macOS it happens with the version 4.0 and with the 4.1.
=================================================================
External Debugger Dump:
=================================================================
(lldb) command source -s 0 '/tmp/mono-gdb-commands.6144'
Executing commands in '/tmp/mono-gdb-commands.6144'.
(lldb) process attach --pid 6144
Process 6144 stopped
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007fff64ff1356 libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
-> 0x7fff64ff1356 <+10>: jae 0x7fff64ff1360 ; <+20>
0x7fff64ff1358 <+12>: movq %rax, %rdi
0x7fff64ff135b <+15>: jmp 0x7fff64fec421 ; cerror
0x7fff64ff1360 <+20>: retq
Target 0: (PushModal.Mac) stopped.
Executable module set to "/Users/jsuarez/Downloads/PM/PushModal.Mac/bin/Debug/PushModal.Mac.app/Contents/MacOS/PushModal.Mac".
Architecture set to: x86_64h-apple-macosx-.
(lldb) thread list
Process 6144 stopped
* thread #1: tid = 0x2a5d18, 0x00007fff64ff1356 libsystem_kernel.dylib`__wait4 + 10, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
thread #2: tid = 0x2a5d2c, 0x00007fff64fef86a libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
thread #3: tid = 0x2a5d30, 0x00007fff64fec266 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
thread #4: tid = 0x2a5d31, 0x00007fff64fef472 libsystem_kernel.dylib`__recvfrom + 10, name = 'Debugger agent'
thread #5: tid = 0x2a5d7e, 0x00007fff64fedbfe libsystem_kernel.dylib`__workq_kernreturn + 10
thread #6: tid = 0x2a5d81, 0x00007fff64fedbfe libsystem_kernel.dylib`__workq_kernreturn + 10
thread #7: tid = 0x2a5da7, 0x0000000000000000
thread #8: tid = 0x2a5da8, 0x00007fff64fec22a libsystem_kernel.dylib`mach_msg_trap + 10, name = 'com.apple.NSEventThread'
thread #9: tid = 0x2a5e0a, 0x00007fff64fef86a libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'tid_cc0b'
thread #10: tid = 0x2a5e0b, 0x00007fff64fec27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10, name = 'Thread Pool Worker'
thread #11: tid = 0x2a5e0c, 0x00007fff64fec27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10, name = 'Thread Pool Worker'
thread #12: tid = 0x2a5e0d, 0x00007fff64fec27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10, name = 'Thread Pool Worker'
(lldb) thread backtrace all
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_IntPtr_UInt64_IntPtr <0x000ee>
at AppKit.NSViewController:TransitionFromViewController <0x0099a>
at Xamarin.Forms.Platform.MacOS.NSViewControllerExtensions:HandleAsyncAnimation <0x00312>
at Xamarin.Forms.Platform.MacOS.ModalPageTracker:PresentModalAsync <0x00932>
at Xamarin.Forms.Platform.MacOS.ModalPageTracker:PushAsync <0x00262>
at Xamarin.Forms.Platform.MacOS.PlatformNavigation:Xamarin.Forms.INavigation.PushModalAsync <0x00122>
at Xamarin.Forms.Internals.NavigationProxy:OnPushModal <0x001f3>
at NavigationImpl:<>n__1 <0x00082>
at <OnPushModal>d__3:MoveNext <0x00372>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x0020a>
at NavigationImpl:OnPushModal <0x0035a>
at Xamarin.Forms.Internals.NavigationProxy:PushModalAsync <0x* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x00007fff64ff1356 libsystem_kernel.dylib`__wait4 + 10
frame #1: 0x0000000101c0237a PushModal.Mac`mono_dump_native_crash_info at mini-posix.c:1112:3 [opt]
frame #2: 0x0000000101c02246 PushModal.Mac`mono_dump_native_crash_info(signal="SIGABRT", ctx=0x00007ffeee10fdf0, info=<unavailable>) at mini-posix.c:1149 [opt]
frame #3: 0x0000000101bf5fa5 PushModal.Mac`mono_handle_native_crash(signal="SIGABRT", ctx=0x00007ffeee10fdf0, info=0x00007ffeee10fd88) at mini-exceptions.c:3290:2 [opt]
frame #4: 0x00007fff650a2b5d libsystem_platform.dylib`_sigtramp + 29
frame #5: 0x00007fff64ff22c7 libsystem_kernel.dylib`__pthread_kill + 11
frame #6: 0x00007fff650adbf1 libsystem_pthread.dylib`pthread_kill + 284
frame #7: 0x00007fff64f5c6a6 libsystem_c.dylib`abort + 127
frame #8: 0x00007fff62138641 libc++abi.dylib`abort_message + 231
frame #9: 0x00007fff621387df libc++abi.dylib`default_termina0012f>
at Xamarin.Forms.Internals.NavigationProxy:OnPushModal <0x001f3>
at Xamarin.Forms.Internals.NavigationProxy:PushModalAsync <0x0012f>
at Xamarin.Forms.Internals.NavigationProxy:PushModalAsync <0x00082>
at PushModal.MainPage:Handle_Clicked <0x0015a>
at Xamarin.Forms.Button:Xamarin.Forms.Internals.IButtonElement.PropagateUpClicked <0x000bf>
at Xamarin.Forms.ButtonElement:ElementClicked <0x001d1>
at Xamarin.Forms.Button:SendClicked <0x0007a>
at Xamarin.Forms.Platform.MacOS.ButtonRenderer:OnButtonActivated <0x000ef>
at AppKit.ActionDispatcher:OnActivated <0x000f9>
at <Module>:runtime_invoke_void__this___object <0x00183>
at <unknown> <0xffffffff>
at ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr <0x000c6>
at AppKit.NSControl:MouseDown <0x00332>
at FormsNSButton:MouseDown <0x00112>
at <Module>:runtime_invoke_void__this___object <0x0031d>
at <unknown> <0xffffffff>
at AppKit.NSApplication:NSApplicationMain <0x001f1>
at AppKit.NSApplication:Main <0x0028a>
at PushModal.Mac.MainClass:Main <0x0016a>
at <Module>:runtime_invoke_void_object <0x00178>
=================================================================
te_handler() + 267
frame #10: 0x00007fff636ebee3 libobjc.A.dylib`_objc_terminate() + 97
frame #11: 0x00007fff6214419e libc++abi.dylib`std::__terminate(void (*)()) + 8
frame #12: 0x00007fff62143f86 libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
frame #13: 0x00007fff62136f99 libc++abi.dylib`__cxa_throw + 113
frame #14: 0x00007fff636e9b51 libobjc.A.dylib`objc_exception_throw + 362
frame #15: 0x0000000101b1b0a0 PushModal.Mac`::xamarin_process_nsexception_using_mode(ns_exception=name: "NSInternalInconsistencyException" - reason: "fromViewController.view.superview must not be nil", throwManagedAsDefault=false) at runtime.m:2358:3
frame #16: 0x0000000101b1af87 PushModal.Mac`::xamarin_process_nsexception(ns_exception=name: "NSInternalInconsistencyException" - reason: "fromViewController.view.superview must not be nil") at runtime.m:2332:2
frame #17: 0x0000000101b2454c PushModal.Mac`xamarin_dyn_objc_msgSendSuper + 268
frame #18: 0x000000010af9be4f
frame #19: 0x00007fff93c69778 AppKit`NSViewBuffer + 40
thread #2, name = 'SGen worker'
frame #0: 0x00007fff64fef86a libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x00007fff650ae56e libsystem_pthread.dylib`_pthread_cond_wait + 722
frame #2: 0x0000000101dfcd21 PushModal.Mac`thread_func [inlined] mono_os_cond_wait(cond=<unavailable>, mutex=<unavailable>) at mono-os-mutex.h:173:8 [opt]
frame #3: 0x0000000101dfcd0e PushModal.Mac`thread_func at sgen-thread-pool.c:165 [opt]
frame #4: 0x0000000101dfcc43 PushModal.Mac`thread_func(data=0x0000000000000000) at sgen-thread-pool.c:196 [opt]
frame #5: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #6: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #7: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
thread #3, name = 'Finalizer'
frame #0: 0x00007fff64fec266 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x0000000101ccc3d0 PushModal.Mac`finalizer_thread [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:90:8 [opt]
frame #2: 0x0000000101ccc3c5 PushModal.Mac`finalizer_thread at mono-coop-semaphore.h:43 [opt]
frame #3: 0x0000000101ccc3ab PushModal.Mac`finalizer_thread(unused=<unavailable>) at gc.c:918 [opt]
frame #4: 0x0000000101d8a457 PushModal.Mac`start_wrapper_internal(start_info=<unavailable>, stack_ptr=<unavailable>) at threads.c:1155:3 [opt]
frame #5: 0x0000000101d8a2b7 PushModal.Mac`start_wrapper(data=0x000060000031c7c0) at threads.c:1215:8 [opt]
frame #6: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
thread #4, name = 'Debugger agent'
frame #0: 0x00007fff64fef472 libsystem_kernel.dylib`__recvfrom + 10
frame #1: 0x0000000101c8569e PushModal.Mac`socket_transport_recv(buf=0x0000700005ae1d6d, len=11) at debugger-agent.c:1108:9 [opt]
frame #2: 0x0000000101c75c46 PushModal.Mac`debugger_thread [inlined] transport_recv(len=11) at debugger-agent.c:1518:9 [opt]
frame #3: 0x0000000101c75c25 PushModal.Mac`debugger_thread(arg=<unavailable>) at debugger-agent.c:9499 [opt]
frame #4: 0x0000000101d8a457 PushModal.Mac`start_wrapper_internal(start_info=<unavailable>, stack_ptr=<unavailable>) at threads.c:1155:3 [opt]
frame #5: 0x0000000101d8a2b7 PushModal.Mac`start_wrapper(data=0x000060000031c340) at threads.c:1215:8 [opt]
frame #6: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
thread #5
frame #0: 0x00007fff650aa3f0 libsystem_pthread.dylib`start_wqthread
thread #6
frame #0: 0x00007fff650aa3f0 libsystem_pthread.dylib`start_wqthread
thread #7
frame #0: 0x0000000000000000
thread #8, name = 'com.apple.NSEventThread'
frame #0: 0x00007fff64fec22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff64fec76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff38f89bee CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff38f8915c CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff38f888be CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00007fff366166a6 AppKit`_NSEventThread + 175
frame #6: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
thread #9, name = 'tid_cc0b'
frame #0: 0x00007fff64fef86a libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x00007fff650ae5a1 libsystem_pthread.dylib`_pthread_cond_wait + 773
frame #2: 0x0000000101e10161 PushModal.Mac`mono_os_cond_timedwait(cond=0x00000001020329d8, mutex=0x0000000102032998, timeout_ms=<unavailable>) at mono-os-mutex.c:44:8 [opt]
frame #3: 0x0000000101e1bae5 PushModal.Mac`mono_thread_info_sleep at mono-coop-mutex.h:102:8 [opt]
frame #4: 0x0000000101e1bab6 PushModal.Mac`mono_thread_info_sleep [inlined] sleep_interruptable(ms=<unavailable>, alerted=0x000070000640edf4) at mono-threads.c:1560 [opt]
frame #5: 0x0000000101e1b97c PushModal.Mac`mono_thread_info_sleep(ms=<unavailable>, alerted=0x000070000640edf4) at mono-threads.c:1592 [opt]
frame #6: 0x0000000101d7eb53 PushModal.Mac`monitor_thread(unused=<unavailable>) at threadpool-worker-default.c:708:8 [opt]
frame #7: 0x0000000101d8a457 PushModal.Mac`start_wrapper_internal(start_info=<unavailable>, stack_ptr=<unavailable>) at threads.c:1155:3 [opt]
frame #8: 0x0000000101d8a2b7 PushModal.Mac`start_wrapper(data=0x00006000003f1e00) at threads.c:1215:8 [opt]
frame #9: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #10: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #11: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
thread #10, name = 'Thread Pool Worker'
frame #0: 0x00007fff64fec27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10
frame #1: 0x0000000101d7f154 PushModal.Mac`worker_thread [inlined] mono_os_sem_timedwait(timeout_ms=31911, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:124:8 [opt]
frame #2: 0x0000000101d7f0bc PushModal.Mac`worker_thread at mono-coop-semaphore.h:57 [opt]
frame #3: 0x0000000101d7f0a5 PushModal.Mac`worker_thread at threadpool-worker-default.c:391 [opt]
frame #4: 0x0000000101d7ef81 PushModal.Mac`worker_thread(unused=<unavailable>) at threadpool-worker-default.c:490 [opt]
frame #5: 0x0000000101d8a457 PushModal.Mac`start_wrapper_internal(start_info=<unavailable>, stack_ptr=<unavailable>) at threads.c:1155:3 [opt]
frame #6: 0x0000000101d8a2b7 PushModal.Mac`start_wrapper(data=0x00006000003b9f40) at threads.c:1215:8 [opt]
frame #7: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #8: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #9: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
thread #11, name = 'Thread Pool Worker'
frame #0: 0x00007fff64fec27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10
frame #1: 0x0000000101d7f154 PushModal.Mac`worker_thread [inlined] mono_os_sem_timedwait(timeout_ms=36929, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:124:8 [opt]
frame #2: 0x0000000101d7f0bc PushModal.Mac`worker_thread at mono-coop-semaphore.h:57 [opt]
frame #3: 0x0000000101d7f0a5 PushModal.Mac`worker_thread at threadpool-worker-default.c:391 [opt]
frame #4: 0x0000000101d7ef81 PushModal.Mac`worker_thread(unused=<unavailable>) at threadpool-worker-default.c:490 [opt]
frame #5: 0x0000000101d8a457 PushModal.Mac`start_wrapper_internal(start_info=<unavailable>, stack_ptr=<unavailable>) at threads.c:1155:3 [opt]
frame #6: 0x0000000101d8a2b7 PushModal.Mac`start_wrapper(data=0x00006000003b9f80) at threads.c:1215:8 [opt]
frame #7: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #8: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #9: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
thread #12, name = 'Thread Pool Worker'
frame #0: 0x00007fff64fec27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10
frame #1: 0x0000000101d7f154 PushModal.Mac`worker_thread [inlined] mono_os_sem_timedwait(timeout_ms=45381, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:124:8 [opt]
frame #2: 0x0000000101d7f0bc PushModal.Mac`worker_thread at mono-coop-semaphore.h:57 [opt]
frame #3: 0x0000000101d7f0a5 PushModal.Mac`worker_thread at threadpool-worker-default.c:391 [opt]
frame #4: 0x0000000101d7ef81 PushModal.Mac`worker_thread(unused=<unavailable>) at threadpool-worker-default.c:490 [opt]
frame #5: 0x0000000101d8a457 PushModal.Mac`start_wrapper_internal(start_info=<unavailable>, stack_ptr=<unavailable>) at threads.c:1155:3 [opt]
frame #6: 0x0000000101d8a2b7 PushModal.Mac`start_wrapper(data=0x00006000003841c0) at threads.c:1215:8 [opt]
frame #7: 0x00007fff650ab2eb libsystem_pthread.dylib`_pthread_body + 126
frame #8: 0x00007fff650ae249 libsystem_pthread.dylib`_pthread_start + 66
frame #9: 0x00007fff650aa40d libsystem_pthread.dylib`thread_start + 13
i have this problem too. is there any ETA or suggested workaround?
Hi,
I am facing the same issue. Is there any workaround for this. It works fine on other platforms (Android, iOS) but on macOS it crashes.
Kind Regards,
Omar Rehman
I'm trying to test this fix but unsure if it is present in 4.3 pre3. Based on my quick test updating to 4.3 pre3 it still is crashing. Also tried it in the latest 4.4 nightly. Which branch would this fix be on or has it not made to a published build yet?
@samhouts Can you provide info on which build this is/will be available in?
This should have been fixed in 4.3.0-pre2. I'll reopen it for further investigation.
My apologies @samhouts I've found out now that the test case application on the original post I logged actually does work at least with 4.3 pre3 where I just now tested. I had previously just tested it in my own application and jumped to a conclusion. I don't have an explanation for the NRE I'm getting in my own app running a similar scenario of just open, close, open. I'll have to investigate that further.
Huh. Here's what I found out. Yes, the test project attached above works. But...simply add a single Entry control into the modal page and boom, it crashes on close of the modal. Technically this looks like a secondary crash problem, but still pretty serious. I'll write it up as a new issue.
Follow-up issue created here. The only difference in the reproduction project is the addition of a single line to the ModalPage.xaml:
<Entry Placeholder="Enter something here" WidthRequest="200" HorizontalOptions="Center" VerticalOptions="Center"/>
Most helpful comment
I can reproduce the problem. In other platforms it works without problems but in macOS it happens with the version 4.0 and with the 4.1.