【问题标题】:Strange crash drawing on canvas on Android 4.0.3. A/libc: Fatal signal 11 (SIGSEGV)Android 4.0.3 上画布上的奇怪崩溃绘图。 A/libc:致命信号 11 (SIGSEGV)
【发布时间】:2012-06-14 21:22:00
【问题描述】:

我正在使用搭载 Android 4.0.3 的低成本平板电脑。这里是日志:

06-11 23:36:04.653: D/SynopticElement(1583): Size changed to 200x200
06-11 23:36:04.693: D/dalvikvm(1583): GC_FOR_ALLOC freed 62K, 12% free 7275K/8199K, paused 33ms
06-11 23:36:04.713: D/SynopticElement(1583): Size changed to 190x190
06-11 23:36:04.733: D/dalvikvm(1583): GC_FOR_ALLOC freed 9K, 12% free 7583K/8583K, paused 22ms
06-11 23:36:04.743: A/libc(1583): Fatal signal 11 (SIGSEGV) at 0xc52c9d4c (code=1)

调试我的代码:

canvas.scale(getWidth(), getWidth()); //I'm drawing a custom component

Paint frameBackgroundPainter = new Paint();
frameBackgroundPainter.setAntiAlias(true);
frameBackgroundPainter.setStyle(Paint.Style.FILL);
frameBackgroundPainter.setColor(0xff000000);

Paint frameBorderPainter = new Paint();
frameBorderPainter.setAntiAlias(true);
frameBorderPainter.setStrokeWidth(0.007f); //canvas is scaled
frameBorderPainter.setStyle(Paint.Style.STROKE);
frameBorderPainter.setColor(0xffaaaaaa);

RectF frameRect = getFrameBorder(); //simply get the Rect to draw on canvas
canvas.drawRect(frameRect, frameBackgroundPainter); //draw the background 

// ---> If I comment this line app does not crash!!!!! <---
canvas.drawRect(frameRect, frameBorderPainter); //draw the border

笔画宽度有问题,我尝试了不同的值:

0.007f -> crash
0.009f -> crash
0.5f -> ok 
0.1f -> ok

由于线宽的值非常低,有人可能会告诉我使用不同的画布比例:好的,但如果我设置 width=0.007f 并在 Android 2.3(平板电脑和手机)上运行应用程序,一切都会好的Android 3.0(平板电脑)...

我没有提出任何以不同方式绘制边框的解决方案,我想知道是否有人知道这是否是 Android 4.0.3 的错误。

我还认为这可能是我的低成本平板电脑的图形硬件问题,不幸的是我没有其他 Android 4.0.3 设备可以进行测试...

我的标签指标:

DisplayMetrics{density=1.0, width=480, height=752, scaledDensity=1.0, xdpi=160.0, ydpi=160.42105}

有关该设备的更多信息,请访问this link

【问题讨论】:

  • 由于内存泄漏,您的内存不足
  • 因为我和我的android 4.0.3手机的状态相同,经过一番研究,发现这是由内存泄漏引起的
  • 感谢您的回复!因此,您确认这是与特定 Android 版本有关的问题。有什么解决办法吗?
  • 当我在手机上测试时,除了 4.0.3 之外,我在其他版本的 android 上没有任何问题,但这仅限于我的手机。其他使用的4.0.3手机似乎没有这个问题。因此,我不能断定这是导致此问题的特定版本的 android。我已经尝试过诸如要求标记垃圾收集之类的方法,但这不一定有效。
  • 谢谢,还以为是安卓手机和ICS的内核数量问题。估计不是。希望您在此之后找到解决问题的方法。

标签: android crash paint android-canvas segmentation-fault


【解决方案1】:

这是在 Intel x86 AVD 上停止 OpenGL-ES 应用程序时的常见错误(每次启动都会在 onStop() 处崩溃)。这是一个快速的解决方案: - 打开 AndroidManifest.xml,将 android:allowClearUserData="true" 标签添加到应用程序节点。

    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme"
            android:allowClearUserData="true" >

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-05
    • 2013-12-10
    • 2015-03-22
    • 1970-01-01
    相关资源
    最近更新 更多