Android 4.3 Bugs in SurfaceView


#1

There are a lot of bugs in Android 4.3 related to the “SurfaceView” class.

As an Android developer I have been really struggling with SurfaceView.

https://code.google.com/p/android/issues/detail?id=58385

Does anyone know if Cocos2d-x is impacted by the bugs in Nexus7 and Nexus10 updates?

I have 3 Java Android applications but no production Cocos2d-x applications, so I cannot see if there are ANR and Crash Reports.

Thanks!


Occasional Crash in libskia.so
#2

Here is another bug that might impact Cocos2d-x

https://code.google.com/p/android/issues/detail?id=58515

The crash reports look like this:

backtrace:
#00 pc 0017f08c /system/lib/libskia.so (S32_D16_nofilter_DX_neon(SkBitmapProcState const&, unsigned int const*, int, unsigned short*)+260)
#01 pc 00074604 /system/lib/libskia.so (SkBitmapProcShader::shadeSpan16(int, int, unsigned short*, int)+148)
#02 pc 000883d0 /system/lib/libskia.so (SkRGB16_Shader16_Blitter::blitRect(int, int, int, int)+312)
#03 pc 000cba2c /system/lib/libskia.so (SkScan::FillIRect(SkIRect const&, SkRegion const*, SkBlitter*)+368)
#04 pc 000cbb24 /system/lib/libskia.so (SkScan::FillRect(SkRect const&, SkRegion const*, SkBlitter*)+152)
#05 pc 000cbc90 /system/lib/libskia.so (SkScan::FillRect(SkRect const&, SkRasterClip const&, SkBlitter*)+84)
#06 pc 0009b078 /system/lib/libskia.so (SkDraw::drawRect(SkRect const&, SkPaint const&) const+660)
#07 pc 0009b728 /system/lib/libskia.so (SkDraw::drawBitmap(SkBitmap const&, SkMatrix const&, SkPaint const&) const+1000)
#08 pc 00095834 /system/lib/libskia.so (SkDevice::drawBitmap(SkDraw const&, SkBitmap const&, SkIRect const*, SkMatrix const&, SkPaint const&)+76)
#09 pc 00095c78 /system/lib/libskia.so (SkDevice::drawBitmapRect(SkDraw const&, SkBitmap const&, SkRect const*, SkRect const&, SkPaint const&)+368)
#10 pc 0008e69c /system/lib/libskia.so (SkCanvas::internalDrawBitmapRect(SkBitmap const&, SkRect const*, SkRect const&, SkPaint const*)+828)
#11 pc 00074303 /system/lib/libandroid_runtime.so
#12 pc 00074459 /system/lib/libandroid_runtime.so
#13 pc 0007448d /system/lib/libandroid_runtime.so
#14 pc 0001dc4c /system/lib/libdvm.so (dvmPlatformInvoke+112)
#15 pc 0004decf /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#16 pc 00027060 /system/lib/libdvm.so
#17 pc 0002b5ec /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#18 pc 0005ff21 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#19 pc 0005ff4b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#20 pc 00054ccb /system/lib/libdvm.so
#21 pc 0000ca58 /system/lib/libc.so (__thread_entry+72)
#22 pc 0000cbd4 /system/lib/libc.so (pthread_create+208)

#3

Thanks @Cory Trese.
I will get an Android device to test it tomorrow.
Do you have any idea to fix this problem?


#4

@Minggo — Thanks for the response. I’m a huge fan. Hope we can protect Cocos2d-x from these Android bugs.


For #58515, the only 100% way to avoid this problem is to avoid libskia.so, which is Google’s buggy new drawing library for Android and Chrome.

The class I was most worried about Cocos2dxBitmap.

As you can see in the bug tracker, the issue starts around this method:

SkDraw::drawBitmap(SkBitmap const&, SkMatrix const&, SkPaint const&) const+1000)

The best way to avoid SkDraw::drawBitmap is to not use android.graphics.Bitmap, which only seems to be in a very few places in CC2DX.


For #58385, you have to avoid using SurfaceView and SurfaceHolder. I am still not sure what role Cocos2dxGLSurfaceView plays in CC2DX Android. I just don’t know enough to say yet.


#5

Thanks @Cory Trese.
I have run TestCpp on Nexus 7 with Android 4.3 inside. It worked perfectly.


#6

Minggo Zhang wrote:

Thanks @Cory Trese.
I have run TestCpp on Nexus 7 with Android 4.3 inside. It worked perfectly.

Same here — Nexus 7 with Android 4.3 does run TestCpp, and CCEditBox “Works”

In production, I see this error reported regularly but can almost never reproduce it.