Ser*_*m's 6 crash android paint segmentation-fault android-canvas
我正在使用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)
Run Code Online (Sandbox Code Playgroud)
调试我的代码:
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
Run Code Online (Sandbox Code Playgroud)
画笔描边宽度有问题,我尝试使用不同的值:
0.007f -> crash
0.009f -> crash
0.5f -> ok
0.1f -> ok
Run Code Online (Sandbox Code Playgroud)
有人可能会告诉我使用不同的画布比例,因为线宽非常低:好的,但如果我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}
Run Code Online (Sandbox Code Playgroud)
有关该设备的更多信息,请访问此链接.
小智 0
这是在 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" >
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4075 次 |
| 最近记录: |