HelloWorld crashes on Archos 101 in CCTexture2D::initPremultipliedATextureWithImage

HelloWorld crashes on Archos 101 in CCTexture2D::initPremultipliedATextureWithImage
0.0 0



So I finally got to testing my app on my hardware device, but it crashed, despite working on the emulator. So I went back to the helloworld sample which I built from scratch, and I got the same crash. However, running the same .apk file on a Samsung Galaxy S gti9000, running Android 2.2, works fine.

I’m using cocos2d-0.99.5-x-0.8.2. The device is an Archos 101 running Android 2.2.1 (archos firmware 2.3.26). As I said, I build the helloworld app from scratch, as described on your wiki page. I’m using NDK r5b.

The call stack is

04-22 14:24:40.164: INFO/DEBUG(1226): #00 pc 00011f54 /system/lib/libc.so
04-22 14:24:40.164: INFO/DEBUG(1226): #01 pc 000191fe /system/lib/libc.so
04-22 14:24:40.164: INFO/DEBUG(1226): #02 pc 000fb194 /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #03 pc 000fb07e /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #04 pc 000fb7a0 /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #05 pc 000fb70a /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #06 pc 000bddbc /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #07 pc 000bdcd6 /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #08 pc 000bda5c /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #09 pc 000ceff8 /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #10 pc 000cf2c6 /data/data/org.cocos2dx.application/lib/libcocos2d.so
04-22 14:24:40.172: INFO/DEBUG(1226): #11 pc 00003e54 /data/data/org.cocos2dx.application/lib/libhelloworld.so
04-22 14:24:40.180: INFO/DEBUG(1226): #12 pc 00016df4 /system/lib/libdvm.so
04-22 14:24:40.180: INFO/DEBUG(1226): #13 pc 00045244 /system/lib/libdvm.so
04-22 14:24:40.180: INFO/DEBUG(1226): #14 pc 0004a9aa /system/lib/libdvm.so
04-22 14:24:40.180: INFO/DEBUG(1226): #15 pc 00028f3c /system/lib/libdvm.so

Using arm-eabi-addr2line, the top part of the stack inside libcocos2d.so is
CCTexture2d.cpp line 441, which is the assert below:

tempData = (unsigned char*)(image->getData()); CCAssert(tempData != NULL, "NULL image data.");

Following the stack up, #06 is CCLabelTTF::setString’s call to texture->initWithString. Following up further, #10 is the call to CCLabelTTF::labelWithString from within CCDirector::setGLDefaultValues(). This is where it’s initialising the FPS counter.

I’m not totally sure where the problem is occuring, though I’d assume it’s probably something to do with initialising the font texture. Perhaps the font being used can’t be found, and there isn’t a fallback image to use?

Anyway, let me know if there’s any more information you could use to help identify the problem. I know these Archos tablets are pretty cheap, but it would be great to get it working on them…

How to use custom font(ttf)?

Cocos2d-x use libskia.so to draw string. Does it exist on your device? Maybe you can use

adb shell ls /system/lib

to check this.


Yes, that lib is there. Here’s the list:

$ adb shell ls /system/lib
bluez-plugin libjnigraphics.so
dsp libjpeg.so
egl liblog.so
hw liblzo.so
libEGL.so libm.so
libETC1.so libmedia.so
libFFTEm.so libmedia_jni.so
libFramebufferUtil.so libmediaplayerservice.so
libGLESv1_CM.so libnativehelper.so
libGLESv2.so libnetlink.so
libIMGegl.so libnetutils.so
libIMGegl.so. libomap_mm_library_jni.so
libLCML.so libomx_aacdec_sharedlibrary.so
libOMX.ITTIAM.AAC.decode.so libomx_amrdec_sharedlibrary.so
libOMX.ITTIAM.AAC.encode.so libomx_amrenc_sharedlibrary.so
libOMX.ITTIAM.MP3.decode.so libomx_avcdec_sharedlibrary.so
libOMX.TI.720P.Decoder.so libomx_m4vdec_sharedlibrary.so
libOMX.TI.720P.Encoder.so libomx_mp3dec_sharedlibrary.so
libOMX.TI.JPEG.decoder.so libomx_sharedlibrary.so
libOMX.TI.JPEG.encoder.so libopencore_author.so
libOMX.TI.VPP.so libopencore_common.so
libOMX.TI.Video.Decoder.so libopencore_download.so
libOMX.TI.Video.encoder.so libopencore_downloadreg.so
libOMX.TI.h264.splt.Encoder.so libopencore_mp4local.so
libOMX_Core.so libopencore_mp4localreg.so
libOpenVG.so libopencore_net_support.so
libOpenVG.so. libopencore_player.so
libOpenVGU.so libopencore_rtsp.so
libOpenVGU.so. libopencore_rtspreg.so
libPVRScopeServices.so libopencorehw.so
libPVRScopeServices.so. libpixelflinger.so
libRS.so libpvr2d.so
libSR_AudioIn.so libpvr2d.so.
libVendor_ti_omx.so libpvrANDROID_WSEGL.so
libVendor_ti_omx_config_parser.so libpvrANDROID_WSEGL.so.
liba2dp.so libpvrPVR2D_FLIPWSEGL.so
libacc.so libpvrPVR2D_FLIPWSEGL.so.
libandroid_runtime.so libpvrPVR2D_FRONTWSEGL.so
libandroid_servers.so libpvrPVR2D_FRONTWSEGL.so.
libaudio.so libreference-cdma-sms.so
libaudioflinger.so libreference-ril.so
libaudiopolicy.so libril.so
libavos.so librs_jni.so
libbinder.so libshm.so
libbluedroid.so libskia.so
libbluetooth.so libskiagl.so
libbluetoothd.so libskiahw.so
libbridge.so libsonivox.so
libc.so libsoundpool.so
libcamera.so libspeech.so
libcamera_client.so libsqlite.so
libcameraservice.so libsrec_jni.so
libcrypto.so libsrv_init.so
libctest.so libsrv_init.so.
libcutils.so libsrv_um.so
libdbus.so libsrv_um.so.
libdectril.so libssl.so
libdiskconfig.so libstagefright.so
libdl.so libstagefright_amrnb_common.so
libdrm1.so libstagefright_avc_common.so
libdrm1_jni.so libstagefright_color_conversion.so
libdspg-ril.so libstagefright_omx.so
libdvm.so libstagefrighthw.so
libemoji.so libstdc++.so
libexif.so libstlport.so
libexpat.so libsurfaceflinger.so
libext2_blkid.so libsurfaceflinger_client.so
libext2_com_err.so libsystem_server.so
libext2_e2p.so libsysutils.so
libext2_profile.so libthread_db.so
libext2_uuid.so libtiutils.so
libext2fs.so libttspico.so
libglslcompiler.so libttssynthproxy.so
libglslcompiler.so. libui.so
libgps.so libusc.so
libhardware.so libusc.so.
libhardware_legacy.so libutils.so
libicudata.so libvoicesearch.so
libicui18n.so libvorbisidec.so
libicuuc.so libwbxml_jni.so
libimageutils.so libwebcore.so
libinterstitial.so libwpa_client.so
libiprouteutil.so libxml2wbxml.so
libjni_latinime.so libz.so
libjni_pinyinime.so libzxing.so


Does Archos 101 released as android sdk 2.2.1, or you upgrate it?
I think the device don’t support full version OpenGL ES 1.1.
You may use other device to test it.


Archos released the device last year running SDK 2.1, but they released an official update to 2.2.1 in November 2010. I didn’t upgrade it manually myself, just installed the official firmware. The firmware update notes are here:

On the official store page, it mentions that the device supports OpenGL EL 2:

After some further debugging, I’ve found what I believe is the source of the problem. It does indeed appear to be inside the skia library.

I added some debug prints to BitmapDC::prepareBitmap, as follows:

CCLog(“BitmapDC: prepareBitmap: width d, height d”, nWidth, nHeight);
// release bitmap
if (m_pBitmap)
delete m_pBitmap;
m_pBitmap = NULL;
if (nWidth > 0 && nHeight > 0)
/* create and init bitmap */
m_pBitmap = new SkBitmap();
if (! m_pBitmap)
CCLog(“BitmapDC: prepareBitmap failed (no bitmap)”);
return false;
/* use rgba8888 and alloc memory */
if )
return false;
int iNewHeight = m_pBitmap~~>height;
int iNewWidth = m_pBitmap~~>width();
int iNewRowBytes = m_pBitmap~~>rowBytes;
/* start with black/transparent pixels */
CCLog(”BitmapDC: prepareBitmap size null~~ no bitmap created“);
CCLog(”BitmapDC: prepareBitmap success");
return true;

The following gets printed to LogCat:

04-26 13:38:57.923: DEBUG/cocos2d-x debug info(3324): BitmapDC: prepareBitmap: width 181, height 40 04-26 13:38:57.923: DEBUG/cocos2d-x debug info(3324): bitmap created: width 0, height 724, rowbytes 2369888 04-26 13:38:57.923: DEBUG/cocos2d-x debug info(3324): BitmapDC: prepareBitmap success

So, it appears that the SkBitmap isn’t being initialised somehow. prepareBitmap is in this case called by drawText, which then goes on to return true. However, back inside CCImage::initWithString, there is the following break condition (line 227):

CC_BREAK_IF(nWidth <= 0 || nHeight <= 0);

As the width == 0, the function the returns. However, by this point the value of bRet has been set to true, from the result of drawText. Thus, the function CCImage::initWithString returns true, even though the image hasn’t been initialised. I believe this is perhaps a bug in the error handling.

So, the question is, why is the SkBitmap’s image data returning bad information after initialisation? Is the source code of this library available?


Also, FYI, if i fix the error handling inside CCImage::initWithString so that it returns false correctly when it detects a bad texture size, the helloworld application runs and displays the sprite as expected. However, there is no ‘Hello World’ text.


Finally, for comparison, here’s the same debug prints using the emulator:

04-26 12:12:07.064: DEBUG/cocos2d-x debug info(320): BitmapDC: prepareBitmap: width 181, height 40 04-26 12:12:07.064: DEBUG/cocos2d-x debug info(320): bitmap created: width 181, height 40, rowbytes 724 04-26 12:12:07.075: DEBUG/cocos2d-x debug info(320): BitmapDC: prepareBitmap success


Bug #475 created.
I just fixed it at https://github.com/cocos2d/cocos2d-x/commit/0b54e1eac39207530fc047b706b3abf19b4d18c4
Thanks for you tracing work!


Thanks Walzer,

However, that doesn’t fix my main problem of the TTF rendering going wrong on my device. However, I can understand that as it’s only on my random tablet, it’s not a priority for your team. In the meantime, I’ve converted my app to use the Bitmap font rendering class, which works correctly, so please dont spend too much time worrying about it :slight_smile:

I shall wait until the ttf solution is fully implemented and then see how it works.