Xamarin.Forms应用程序更新到13.1后在iOS上崩溃

Xamarin.Forms应用程序更新到13.1后在iOS上崩溃,xamarin,xamarin.forms,xamarin.ios,core-animation,ios13,Xamarin,Xamarin.forms,Xamarin.ios,Core Animation,Ios13,我在mac上使用Visual Studio 2017和Visual Studio 2017。Mono版本是5.18.1,Xamarin.iOS版本是12.4(我想)。该应用程序运行良好,没有任何问题。最近,我将Windows和Mac上的Visual Studio更新到2019年,Xamarin.iOS版本更新到13.4。现在,该应用程序在模拟器和iOS 13.1的iPhone上都出现了“奇怪”的崩溃。但在iOS 12.4的模拟器上,该应用程序运行平稳。此外,app store中发布的应用程序(使

我在mac上使用Visual Studio 2017和Visual Studio 2017。Mono版本是5.18.1,Xamarin.iOS版本是12.4(我想)。该应用程序运行良好,没有任何问题。最近,我将Windows和Mac上的Visual Studio更新到2019年,Xamarin.iOS版本更新到13.4。现在,该应用程序在模拟器和iOS 13.1的iPhone上都出现了“奇怪”的崩溃。但在iOS 12.4的模拟器上,该应用程序运行平稳。此外,app store中发布的应用程序(使用Xamarin.iOS 12.4构建)在iOS 13.1设备中也能正常运行

在做一些与动画相关的工作时,应用程序似乎正在崩溃,下面是AppCenter的崩溃日志

Application Specific Information:
*** Terminating app due to uncaught exception 'SIGABRT', reason: 'Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
Native stack trace:

**some native trace**

Xamarin Exception Stack:
Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
Native stack trace:

**some native trace**

at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:406
  at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/runtime/Delegates.generated.cs:128
  at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
  at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSendSuper(intptr,intptr)
  at UIKit.UIView.LayoutSubviews () [0x00023] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/UIView.g.cs:1290
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].LayoutSubviews () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:289
  at null.null
  at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSendSuper(intptr,intptr)
  at UIKit.UIView.LayoutSubviews () [0x00023] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/UIView.g.cs:1290
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].LayoutSubviews () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:289
  at null.null
  at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr)
  at CoreAnimation.CATransaction.Commit () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/CATransaction.g.cs:90
  at Xamarin.Forms.Platform.iOS.CADisplayLinkTicker.StartThread () [0x0003a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CADisplayLinkTicker.cs:61
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:74
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:968
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:899
  at System.Threading.ThreadHelper.ThreadStart () [0x00008] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:111

有人知道这里有什么问题吗(

不知何故,当我从与崩溃相关的视图中删除
Xamarin.Forms.Editor
时,没有发生崩溃。我想如果我的代码没有做什么,那么可能是渲染器(EditorRenderer)可能负责在后台线程上更新UI或其他什么。所以我更新了
Xamarin.Forms
版本,它工作正常


因此,将Xamarin.Forms版本更新到3.6解决了问题!

当我从与崩溃相关的视图中删除
Xamarin.Forms.Editor
时,没有发生崩溃。我想如果我的代码没有做什么,那么可能是渲染器(EditorRenderer)可能负责在后台线程上更新UI或其他什么。所以我更新了
Xamarin.Forms
版本,它工作正常



因此,将Xamarin.Forms版本更新到3.6解决了这个问题!

这可能意味着您正在后台线程或类似程序中更新某些UI。您是否可以调试代码以查看崩溃发生的位置,并检查是否正在更新UI。您可以使用
dispatch\u async(dispatch\u get\u main\u queue(),^{});
在主线程中运行代码。@JackHua MSFT调试没有帮助。调试过程中发生的崩溃,在我打开应用程序时没有附加调试器。这很奇怪。调试过程中发生的崩溃,所以你能知道它在哪个页面崩溃吗?检查那里的代码。上面注释中的代码示例用于Obj-C在Xamarin.Forms中,使用以下命令来保证代码在UI/主线程上运行:
Device.beginInvokeMainThread(操作)
我已经用助手类检查了所有代码,以检查当前线程是否为主线程。但是与崩溃相关的所有位置都在主线程上。所以不是我。这可能意味着你正在更新后台线程或类似线程中的某个UI。你能调试代码以查看崩溃发生的位置并进行检查吗如果您正在那里更新UI,您可以使用
dispatch\u async(dispatch\u get\u main\u queue(),^{});
在主线程中运行代码。@JackHua MSFT调试没有帮助。调试过程中发生的崩溃,在我打开应用程序时没有附加调试器。这很奇怪。调试过程中发生的崩溃,所以你能知道它在哪个页面崩溃吗?检查那里的代码。上面注释中的代码示例用于Obj-C在Xamarin.Forms中,使用以下命令来保证代码在UI/主线程上运行:
Device.beginInvokeMainThread(操作)
我已经用助手类检查了所有代码,以检查当前线程是否是主线程。但是与崩溃相关的所有位置都在主线程上。所以不是我。我在4.3.0.851321-pre3上遇到了相同的崩溃。有很多类似的崩溃!你可以在&.上找到更多的崩溃。在我的例子中,应用程序cr当它在做一些动画的时候会灰暗。面对这个问题,我使用的是版本4.4.0.9。@SufyanAhmad如果你能找到导致崩溃的页面/视图,我建议逐个删除/添加控件,直到你找到导致崩溃的控件为止。这是我确定编辑器负责崩溃的方法。我enco在4.3.0.851321-pre3上遇到了同样的崩溃。有很多类似的崩溃!你可以在&上找到更多的崩溃。在我的例子中,应用程序在做一些动画时崩溃了。面对这个问题,我使用的是版本4.4.0.9。@SufyanAhmad如果你能找到导致崩溃的页面/视图,我建议删除/添加控件直到你找到导致崩溃的控件。这是我确定编辑器对崩溃负责的方法。