0

私のcocos2dxゲームから、私は結果のために別の活動を賞賛しています、そして私がゲーム活動に戻るとき、それは次のスタックでクラッシュします。ログを追加することで、

applicationWillEnterForeground()

CCDirector::sharedDirector()->resume();

正常に実行すると、アプリがクラッシュします。同様に、ホームボタンを押してアプリを一時停止して再度開くと、動作がわかります。ただし、その場合、スタックトレースは
「/system/lib/egl/libGLESv2_adreno200.so」
ファイルを指します。

03-25 12:46:49.659: D/cocos2d-x debug info(21764): AppDelegate::applicationWillEnterForeground done
03-25 12:46:49.739: I/GLThread(21764): noticed surfaceView surface acquired tid=16
03-25 12:46:49.739: W/EglHelper(21764): start() tid=16
03-25 12:46:49.769: W/EglHelper(21764): createContext com.google.android.gles_jni.EGLContextImpl@405924d8 tid=16
03-25 12:46:49.769: I/Main thread(21764): onWindowResize waiting for render complete from tid=16
03-25 12:46:49.769: W/GLThread(21764): egl createSurface
03-25 12:46:49.769: W/EglHelper(21764): createSurface()  tid=16
03-25 12:46:49.769: W/GLThread(21764): onSurfaceCreated
03-25 12:46:50.119: D/cocos2d-x debug info(21764): reload all texture
03-25 12:46:50.289: W/GLThread(21764): onSurfaceChanged(320, 240)


********** Crash dump: **********
Build fingerprint: 'samsung/GT-S5670/GT-S5670:2.3.4/GINGERBREAD/XWKQ2:user/release-keys' pid: 20072, tid: 20083  >>> com.xxxx.yyyo <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 482b7000
Stack frame #00  pc 0000cd8c  /system/lib/libc.so
Stack frame #01  pc 00168cde  /mnt/asec/com.xxxx.yyyo-2/lib/libgame.so: Routine _initWithRawData in D:/Dev/cocos2d-2.0-x-2.0.4/yyyo-21mar/proj.android/../libs/cocos2dx/platform/CCImageCommon_cpp.h:593
Stack frame #02  pc 00168174  /mnt/asec/com.xxxx.yyyo-2/lib/libgame.so: Routine initWithImageData in D:/Dev/cocos2d-2.0-x-2.0.4/yyyo-21mar/proj.android/../libs/cocos2dx/platform/CCImageCommon_cpp.h:148

UPDATE Visual Studioで同じ動作をエミュレートしようとし、コールスタックを考え出しました

libcocos2d.dll!cocos2d::CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent)   Line 576
libcocos2d.dll!cocos2d::CCImage::initWithImageData(void * pData, int nDataLen, cocos2d::CCImage::EImageFormat eFmt, int nWidth, int nHeight, int nBitsPerComponent) Line 126    C++
libcocos2d.dll!cocos2d::CCTextureCache::addImage(const char * path) Line 440    C++
libcocos2d.dll!cocos2d::CCSprite::initWithFile(const char * pszFilename) Line 254   C++
libcocos2d.dll!cocos2d::CCSprite::create(const char * pszFileName) Line 104 C++
Game.win32.exe!Ball::Ball(b2World * world, std::map<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >,JSONValue *,std::less<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > >,std::allocator<std::pair<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > const ,JSONValue *> > > jBall, float boxScaleFactor) Line 20 C++
.
.
.
Game.win32.exe!Game::singleton() Line 27    C++
Game.win32.exe!AppDelegate::applicationDidFinishLaunching() Line 30 C++ 

メソッド_initWithRawDataはここにあります

bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeight,   int nBitsPerComponent)
{
bool bRet = false;
do 
{
    CC_BREAK_IF(0 == nWidth || 0 == nHeight);

    m_nBitsPerComponent = nBitsPerComponent;
    m_nHeight   = (short)nHeight;
    m_nWidth    = (short)nWidth;
    m_bHasAlpha = true;

    // only RGBA8888 supported
    int nBytesPerComponent = 4;
    int nSize = nHeight * nWidth * nBytesPerComponent;
    m_pData = new unsigned char[nSize];
    CC_BREAK_IF(! m_pData);
    memcpy(m_pData, pData, nSize);

    bRet = true;
} while (0);
return bRet;
}

UPDATE2 問題の原因がアドレスの重複であることがわかりました。memcpyの前に以下のコードを追加しました

if(pData > (m_pData + nSize)) {
        CCLOG("CCImage::_initWithRawData source > dest + size ");
memcpy(m_pData, pData, nSize);
    } else {
        CCLOG("CCImage::_initWithRawData error source < dest + size ");
memmove(m_pData, pData, nSize);
    }

として出力されました

CCImage::_initWithRawData error source < dest + size 

しかし、アプリはまだmemmoveでクラッシュしています。

4

1 に答える 1

0

画像スプライトを作成するために、Androidからcocos2dxに生データを送信していることに気付きました。そして、onPauseは生データがAndroid側からリリースされていて、cocos2dxが再開しているときに、ポインターの場所で生画像データを見つけることができなかったため、クラッシュしていました。

于 2013-03-28T05:24:57.070 に答える