Cocos2dx v3.4 Release Mode Error

  • Furkanzmc
    Likes 0

    Problem Description

    I'm trying to build my game on release mode using CMake. I disabled DEBUG_MODE and successfully built the project but when I run it I get an error I don't get in debug mode.

    Error Image

    Here's the call stack.

     

    KernelBase.dll!763d2f71()   Unknown
        [Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]    
        [External Code] 
    >   SortingGame.exe!BackgroundBuilder::configureTimeLabel(const cocos2d::Vec2 timeContainerEndPos) Line 236 C++
        SortingGame.exe!BackgroundBuilder::configureTimeContainerSprite() Line 226  C++
        SortingGame.exe!GameScene::configureTimeContainerSprite() Line 352  C++
        SortingGame.exe!GameScene::configureScene() Line 210    C++
        SortingGame.exe!GameScene::init() Line 130  C++
        SortingGame.exe!GameScene::create() Line 25 C++
        SortingGame.exe!LoadingScreen::onKeyPressed(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event * event) Line 168   C++
        [External Code] 
        SortingGame.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 24   C++
        [External Code]

    BackgroundBuilder::configureTimeContainerSprite() function gets called only once. If I call BackgroundBuilder::configureTimeContainerSprite() in BackgroundBuilder::BackgroundBuilder() the error doesn't occur in BackgroundBuilder::configureTimeContainerSprite() but in main.cpp file's return Application::getInstance()->run(); line. The error is the same here too. I get the same error when I build the project with Visual Studio 2013.

  • Sonar Systems admin
    Likes 0

    What platform are you developing for?

  • Furkanzmc
    Likes 0

    Windwos 8.1 x64


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    Is that the platform you want to run your app on or just the platform you are coding on?


    This reply has been verified.
  • Furkanzmc
    Likes 0

    I’m developing on and for Windows 8.


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    Does this happen with a fresh project as well?


    This reply has been verified.
  • Furkanzmc
    Likes 0

    If you mean a newly created, non related project, no it does not happen. I also have another project and it works fine in release mode. It’s specific to this project.


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    It seems to be at Vec2, try chaning the Vec2 to 2 float variables for now and see if that works?


    This reply has been verified.
  • Furkanzmc
    Likes 0

    it wasnt’ with Vec2. Here’s what I did so far.

    This is the function that calls the functions in BackgroundBuilder. So the order is GameScene::configureTimeContainerSprite() → BackgroundBuilder::configureTimeContainerSprite() → BackgroundBuilder.configureTimeLabel();

    Here is the first version that causes the above troublem.

    void GameScene::configureTimeContainerSprite(BackgroundBuilder &backgroundBuilder)
    {
        GameManager::getInstance()->m_Logger << FileLogger::LogType::LOG_INFO << "GameScene::configureTimeContainerSprite";
        std::tuple tuple = backgroundBuilder.configureTimeContainerSprite();
        m_SpriteTimeContainer = std::get<0>(tuple);
        m_SpriteSandglass = std::get<1>(tuple);
        m_LabelCountdown = std::get<2>(tuple);

        this->addChild(m_SpriteTimeContainer, LAYER::HUD);
        this->addChild(m_SpriteSandglass, LAYER::HUD);
        this->addChild(m_LabelCountdown, LAYER::SCORE_HUD + 1);
    }

    std::tuple BackgroundBuilder::configureTimeContainerSprite()
    {
        Sprite *spriteTimeContainer = Sprite::create(m_AssetKeys.at("Time_Container"));
        spriteTimeContainer->setScale(m_BackgroundScale.x, m_BackgroundScale.y);
        Size scaledSize = spriteTimeContainer->getBoundingBox().size;
        Vec2 endPos(m_VisibleSize.width / 2, m_VisibleSize.height - scaledSize.height / 2);
        spriteTimeContainer->setPosition(endPos.x, m_VisibleSize.height + scaledSize.height);
        MoveTo *move = MoveTo::create(m_AnimationDuration, endPos);
        Sequence *seq = Sequence::create(DelayTime::create(1), EaseElasticOut::create(move), nullptr);
        spriteTimeContainer->runAction(seq);

        Sprite *spriteSandglass = Sprite::create(m_AssetKeys.at("Sandglass_Green"));
        spriteSandglass->setScale(m_BackgroundScale.x);
        spriteSandglass->setPosition(spriteTimeContainer->getPositionX() - spriteSandglass->getBoundingBox().size.width / 2, spriteTimeContainer->getPositionY());
        Vec2 endPosSandglass = endPos;
        endPosSandglass.x = spriteTimeContainer->getPositionX() - spriteSandglass->getBoundingBox().size.width;
        endPosSandglass.y = endPos.y + spriteSandglass->getBoundingBox().size.height / 4;
        move = MoveTo::create(m_AnimationDuration, endPosSandglass);
        seq = Sequence::create(DelayTime::create(1), EaseElasticOut::create(move), nullptr);
        spriteSandglass->runAction(seq);

        return std::make_tuple(spriteTimeContainer, spriteSandglass, configureTimeLabel(endPos));
    }

    Label *BackgroundBuilder::configureTimeLabel(const Vec2 &timeContainerEndPos)
    {
        const std::string gameDuration = std::to_string(GameSettings::getInstance()->getGameDuration());
        Label *labelCountdown = Label::createWithTTF(gameDuration, "fonts/Mexe.otf", 130);
        labelCountdown->setScale(m_BackgroundScale.x);

        Vec2 endPos;
        endPos.x = timeContainerEndPos.x + labelCountdown->getBoundingBox().size.width / 2.5f;
        endPos.y = timeContainerEndPos.y + labelCountdown->getBoundingBox().size.height / 4.f;

        labelCountdown->setPosition(endPos.x, m_VisibleSize.height + labelCountdown->getBoundingBox().size.height);

        MoveTo *move = MoveTo::create(m_AnimationDuration, endPos);
        Sequence *seq = Sequence::create(DelayTime::create(1), EaseElasticOut::create(move), nullptr);
        labelCountdown->runAction(seq);

        return labelCountdown;
    }

    With the above usage the get methods of Label caused the same problem of which I shared the screen shot. When I use, say, labelCountdown.setString(“asd”) there wasn’t any problems. So instead of using the above code I converted it to this. And the only difference is I use the configureTimeLabel method outside of BackroundBuilder::configureTimeContainerSprite

    void GameScene::configureTimeContainerSprite(BackgroundBuilder &backgroundBuilder)
    {
        GameManager::getInstance()->m_Logger << FileLogger::LogType::LOG_INFO << "GameScene::configureTimeContainerSprite";
        std::tuple tuple = backgroundBuilder.configureTimeContainerSprite();
        m_SpriteTimeContainer = std::get<0>(tuple);
        m_SpriteSandglass = std::get<1>(tuple);
        m_LabelCountdown = backgroundBuilder.configureTimeLabel(std::get<2>(tuple));

        this->addChild(m_SpriteTimeContainer, LAYER::HUD);
        this->addChild(m_SpriteSandglass, LAYER::HUD);
        this->addChild(m_LabelCountdown, LAYER::SCORE_HUD + 1);
        GameManager::getInstance()->m_Logger << FileLogger::LogType::LOG_INFO << "GameScene::configureTimeContainerSprite END";
    }

    std::tuple BackgroundBuilder::configureTimeContainerSprite()
    {
        Sprite *spriteTimeContainer = Sprite::create(m_AssetKeys.at("Time_Container"));
        spriteTimeContainer->setScale(m_BackgroundScale.x, m_BackgroundScale.y);
        Size scaledSize = spriteTimeContainer->getBoundingBox().size;
        Vec2 endPos(m_VisibleSize.width / 2, m_VisibleSize.height - scaledSize.height / 2);
        spriteTimeContainer->setPosition(endPos.x, m_VisibleSize.height + scaledSize.height);
        MoveTo *move = MoveTo::create(m_AnimationDuration, endPos);
        Sequence *seq = Sequence::create(DelayTime::create(1), EaseElasticOut::create(move), nullptr);
        spriteTimeContainer->runAction(seq);

        Sprite *spriteSandglass = Sprite::create(m_AssetKeys.at("Sandglass_Green"));
        spriteSandglass->setScale(m_BackgroundScale.x);
        spriteSandglass->setPosition(spriteTimeContainer->getPositionX() - spriteSandglass->getBoundingBox().size.width / 2, spriteTimeContainer->getPositionY());
        Vec2 endPosSandglass = endPos;
        endPosSandglass.x = spriteTimeContainer->getPositionX() - spriteSandglass->getBoundingBox().size.width;
        endPosSandglass.y = endPos.y + spriteSandglass->getBoundingBox().size.height / 4;
        move = MoveTo::create(m_AnimationDuration, endPosSandglass);
        seq = Sequence::create(DelayTime::create(1), EaseElasticOut::create(move), nullptr);
        spriteSandglass->runAction(seq);

        return std::make_tuple(spriteTimeContainer, spriteSandglass, endPos);
    }

    Label *BackgroundBuilder::configureTimeLabel(const Vec2 &timeContainerEndPos)
    {
        const std::string gameDuration = std::to_string(GameSettings::getInstance()->getGameDuration());
        Label *labelCountdown = Label::createWithTTF(gameDuration, "fonts/Mexe.otf", 130);
        labelCountdown->setScale(m_BackgroundScale.x);

        Vec2 endPos;
        endPos.x = timeContainerEndPos.x + labelCountdown->getBoundingBox().size.width / 2.5f;
        endPos.y = timeContainerEndPos.y + labelCountdown->getBoundingBox().size.height / 4.f;

        labelCountdown->setPosition(endPos.x, m_VisibleSize.height + labelCountdown->getBoundingBox().size.height);

        MoveTo *move = MoveTo::create(m_AnimationDuration, endPos);
        Sequence *seq = Sequence::create(DelayTime::create(1), EaseElasticOut::create(move), nullptr);
        labelCountdown->runAction(seq);

        return labelCountdown;
    }

    With this code, the same problem doesn’t occur. But a new one arises in a different place. And here it is:


  • Sonar Systems admin
    Likes 0

    go back through the code you added, and add the code line by line to help identify which line is the problem.


    This reply has been verified.
  • Furkanzmc
    Likes 0

    That wasn’t the problem. I was able to get a more detailed stack log. Here it is:

    [ERROR]: Walking stack.

    0: RaiseException -> 
    1: CxxThrowException -> 
    2: std::_Xout_of_range -> 
    3: std::map<enum cocos2d::Texture2D::PixelFormat,cocos2d::Texture2D::PixelFormatInfo const ,std::less<enum cocos2d::Texture2D::PixelFormat>,std::allocator<std::pair<enum cocos2d::Texture2D::PixelFormat const ,cocos2d::Texture2D::PixelFormatInfo const > > >::at -> 
    4: cocos2d::Texture2D::updateWithData -> 
    5: cocos2d::FontAtlas::prepareLetterDefinitions -> 
    6: cocos2d::Label::alignText -> 
    7: cocos2d::Label::updateContent -> 
    8: cocos2d::Label::visit -> 
    9: cocos2d::Node::visit -> 
    10: cocos2d::Node::visit -> 
    11: cocos2d::Node::visit -> 
    12: cocos2d::TransitionCrossFade::onEnter -> 
    13: cocos2d::Director::setNextScene -> 
    14: cocos2d::Director::drawScene -> 
    15: cocos2d::DisplayLinkDirector::mainLoop -> 
    16: cocos2d::Application::run -> 
    17: main -> c:\users\furkanzmc\sourcetree\sortinggame\proj.win32\main.cpp(26)
    18: __tmainCRTStartup -> f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c(626)
    19: BaseThreadInitThunk -> 
    20: RtlInitializeExceptionChain -> 
    21: RtlInitializeExceptionChain -> 
    End of stack walk.


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    What wasn’t the problem?

Login to reply