android - 如何解决 Xamarin Android 中的 SIGSEGV 崩溃问题

标签 android xamarin xamarin.android segmentation-fault

我们刚刚向 Play 商店发布了新版本的 Android 应用程序,现在用户报告崩溃。我们能够重现,但是它在整个应用程序中随机发生并且是 SIGSEGV 崩溃。

https://gist.github.com/justintoth/78abbd4b647de3ee04037631e921198f

根据回溯,最后两次崩溃似乎都与 ImageView 有关。

崩溃#1:

A/DEBUG(6953): #00 pc 000c1178 /system/lib/libandroid_runtime.so 04-13 17:26:53.640: A/DEBUG(6953): #01 pc 020813ce /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.view.RenderNode.nGetTransformMatrix+138) 04-13 17:26:53.640: A/DEBUG(6953): #02 pc 020845cd /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.view.RenderNode.getMatrix+89) 04-13 17:26:53.640: A/DEBUG(6953): #03 pc 020082dd /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.view.View.getMatrix+89) 04-13 17:26:53.640: A/DEBUG(6953):

04 pc 02061f2b /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.view.ViewGroup.invalidateChild+119) 04-13

17:26:53.640: A/DEBUG(6953): #05 pc 0200bda1 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.view.View.invalidateInternal+541) 04-13 17:26:53.640: A/DEBUG(6953): #06 pc 0200ba3b /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.view.View.invalidate+103) 04-13 17:26:53.640: A/DEBUG(6953):

07 pc 0200b822 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.view.View.invalidate+46) 04-13 17:26:53.640:

A/DEBUG(6953): #08 pc 0216c878 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.widget.ImageView.setImageDrawable+180)

崩溃#2:

/system/lib/libskia.so (_ZN8SkMatrix13setRectToRectERK6SkRectS2_NS_10ScaleToFitE+289) 04-13 17:59:57.981: A/DEBUG(8047): #01 pc 000f7c9d /system/lib/libandroid_runtime.so (_ZN7android12SkMatrixGlue13setRectToRectEP7_JNIEnvP8_jobjectxS4_S4_i+134) 04-13 17:59:57.981: A/DEBUG(8047): #02 pc 01936e62 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.graphics.Matrix.native_setRectToRect+190) 04-13 17:59:57.981: A/DEBUG(8047): #03 pc 01939373 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.graphics.Matrix.setRectToRect+127) 04-13 17:59:57.981: A/DEBUG(8047): #04 pc 0216977d /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.widget.ImageView.configureBounds+1625) 04-13 17:59:57.981: A/DEBUG(8047): #05 pc 0216b253 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.widget.ImageView.invalidateDrawable+159) 04-13 17:59:57.981: A/DEBUG(8047): #06 pc 0170f783 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.graphics.drawable.Drawable.invalidateSelf+79) 04-13 17:59:57.981: A/DEBUG(8047): #07 pc 017100f5 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.graphics.drawable.Drawable.setVisible+81) 04-13 17:59:57.981: A/DEBUG(8047): #08 pc 0216a91f /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.widget.ImageView.updateDrawable+619) 04-13 17:59:57.981: A/DEBUG(8047): #09 pc 0216c829 /system/framework/x86/boot-framework.oat (offset 0x1588000) (android.widget.ImageView.setImageDrawable+101)

我不清楚如何对 SIGSEGV 崩溃进行故障排除,因为它们似乎是低级别的并且不包含来 self 的实际代码的堆栈跟踪。它们是作为应用程序开发人员可以控制的一般崩溃,还是 Xamarin 错误?我最好尝试降级我的 Xamarin 包(这可能很困难,他们的下载页面现在只提供最后两个版本......)有人有这方面的经验吗?

最佳答案

Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0

您的应用正在访问一个引用(对象/等等),该引用已被释放/取消引用,因为它的地址为零 (0x0)。

(6953): backtrace:
~~~
(android.view.RenderNode.getMatrix+89)
(android.view.View.getMatrix+89)
(android.view.ViewGroup.invalidateChild+119)
(android.view.View.invalidateInternal+541)
(android.view.View.invalidate+103)
(android.view.View.invalidate+46)
(android.widget.ImageView.setImageDrawable+180)
~~~

在这种情况下,您正在为 ImageView 分配一个错误的可绘制对象,BitMap 是 Release 或已被 GC 处理或只是不可用。

您可以使用 mono-symbolicate 向该 logcat 回溯/崩溃添加符号:

关于android - 如何解决 Xamarin Android 中的 SIGSEGV 崩溃问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49825657/

相关文章:

android - 如何为android :attr/borderlessButtonStyle button指定背景正常颜色

c# - 获取在 ExportRenderer 中调用 PageRenderer 的 ContentPage 的类型

c# - 如何使用 MonoMac/Xamarin 打开或创建新窗口?

c# - 是否可以在 Xamarin.Forms 中以独立于平台的代码访问外部存储?

android - 尽管存在图像,BitmapFactory 返回 null

java - 将本地日期和时间转换为 UTC,然后将 UTC 转换为本地日期和时间

android - 具有跨平台单点登录配置的服务器端访问不清楚

ios - iOS 上的 ForceUpdateSize ListView 问题

c# - 如何在 Xamarin Android 中实现 JobScheduler

android - Xamarin.Forms Android 推送通知不出现