我正在尝试通过Xamarin DependencyService
显示加载视图。我使用的想法是将ContentPage
传递到特定于平台并通过DependencyService
注册的服务。但是,尽管事情可以在Android上正常运行,但在iOS上,我却得到了一些非常奇怪的行为。
这是导致本机崩溃的位:
public void ShowLoadingPage()
{
UIApplication.SharedApplication.KeyWindow.AddSubview(_nativeView);
}
_nativeView
是根据传入的XF NativeView
创建的渲染器的ContentPage
。
在某些我称为ShowLoadingPage()
的页面上,即使ContentPage
是一个清晰的叠加层,我也会得到一个背景为白色(完全不透明)的叠加层。
在发生崩溃的特定页面上,它根本没有显示。
这是崩溃:
MyApp.iOS[12354:641574] critical: Stacktrace:
MyApp.iOS[12354:641574] critical: at <unknown> <0xffffffff>
MyApp.iOS[12354:641574] critical: at (wrapper managed-to-native) Foundation.NSObject.xamarin_release_managed_ref (intptr,Foundation.NSObject) [0x00008] in <0b60c1467e7449608ac42f9c7bbfdd05>:0
MyApp.iOS[12354:641574] critical: at Foundation.NSObject.ReleaseManagedRef () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSObject2.cs:221
MyApp.iOS[12354:641574] critical: at Foundation.NSObject/NSObject_Disposer.Drain (Foundation.NSObject) [0x00054] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/Foundation/NSObject2.cs:803
MyApp.iOS[12354:641574] critical: at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <0b60c1467e7449608ac42f9c7bbfdd05>:0
MyApp.iOS[12354:641574] critical: at <unknown> <0xffffffff>
MyApp.iOS[12354:641574] critical: at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) [0x0005c] in <0b60c1467e7449608ac42f9c7bbfdd05>:0
MyApp.iOS[12354:641574] critical: at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:79
MyApp.iOS[12354:641574] critical: at UIKit.UIApplication.Main (string[],string,string) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:63
MyApp.iOS[12354:641574] critical: at MyApp.iOS.Application.Main (string[]) [0x00001] in /MyApp/XamarinApp/iOS/Main.cs:12
MyApp.iOS[12354:641574] critical: at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <eb83f305fed14faeaac09db08c7720da>:0
MyApp.iOS[12354:641574] critical:
Native stacktrace:
MyApp.iOS[12354:641574] critical: 0 MyApp.iOS 0x0000000101b07324 mono_handle_native_crash + 244
MyApp.iOS[12354:641574] critical: 1 MyApp.iOS 0x0000000101b15600 mono_sigsegv_signal_handler + 288
MyApp.iOS[12354:641574] critical: 2 libsystem_platform.dylib 0x0000000109441f5a _sigtramp + 26
MyApp.iOS[12354:641574] critical: 3 libsystem_malloc.dylib 0x00000001091be98b free_tiny + 392
MyApp.iOS[12354:641574] critical: 4 libobjc.A.dylib 0x0000000107e276a7 class_getInstanceMethod + 53
MyApp.iOS[12354:641574] critical: 5 MyApp.iOS 0x0000000101cce6e4 _ZL12is_user_typeP11objc_object + 36
MyApp.iOS[12354:641574] critical: 6 MyApp.iOS 0x0000000101ccd6f9 xamarin_release_managed_ref + 25
MyApp.iOS[12354:641574] critical: 7 ??? 0x00000001295861ed 0x0 + 4988625389
MyApp.iOS[12354:641574] critical: 8 ??? 0x000000012a0ceb79 0x0 + 5000457081
MyApp.iOS[12354:641574] critical: 9 MyApp.iOS 0x0000000101b18683 mono_jit_runtime_invoke + 1443
MyApp.iOS[12354:641574] critical: 10 MyApp.iOS 0x0000000101bee0ff mono_runtime_invoke_checked + 127
MyApp.iOS[12354:641574] critical: 11 MyApp.iOS 0x0000000101bf181c mono_runtime_invoke + 76
MyApp.iOS[12354:641574] critical: 12 MyApp.iOS 0x0000000101cd5cf2 xamarin_invoke_trampoline + 6018
MyApp.iOS[12354:641574] critical: 13 MyApp.iOS 0x0000000101cdc7dd xamarin_arch_trampoline + 189
MyApp.iOS[12354:641574] critical: 14 MyApp.iOS 0x0000000101cddc11 xamarin_x86_64_common_trampoline + 110
MyApp.iOS[12354:641574] critical: 15 Foundation 0x0000000105ab6d5e __NSThreadPerformPerform + 330
MyApp.iOS[12354:641574] critical: 16 CoreFoundation 0x000000010700dbb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
MyApp.iOS[12354:641574] critical: 17 CoreFoundation 0x0000000106ff24af __CFRunLoopDoSources0 + 271
MyApp.iOS[12354:641574] critical: 18 CoreFoundation 0x0000000106ff1a6f __CFRunLoopRun + 1263
MyApp.iOS[12354:641574] critical: 19 CoreFoundation 0x0000000106ff130b CFRunLoopRunSpecific + 635
MyApp.iOS[12354:641574] critical: 20 GraphicsServices 0x000000010bf64a73 GSEventRunModal + 62
MyApp.iOS[12354:641574] critical: 21 UIKit 0x00000001038bb057 UIApplicationMain + 159
MyApp.iOS[12354:641574] critical: 22 ??? 0x0000000127b08b37 0x0 + 4960848695
MyApp.iOS[12354:641574] critical: 23 ??? 0x0000000127b08893 0x0 + 4960848019
MyApp.iOS[12354:641574] critical:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
为什么会这样?是否有可以从崩溃日志中解密的内容?
答案 0 :(得分:0)
已解决。刚刚将Xamarin.Forms的版本从2.3.x更新到了2.5.x。