Transition crash

Hello everybody!
I have a problem: when the transition is running I close the application and it crash on the line CCNode::189

  CCASSERT(!_running, "Node still marked as running on node destruction! Was base class onExit() called in derived class onExit() implementations?");

Source code:

#include "SplashScene.h"
#include "GameScene.h"

USING_NS_CC;

Scene* SplashScene::createScene(NextScene_t nextScene)
{
    auto scene = Scene::create();
	auto layer = SplashScene::create();
	layer->setNextScene(nextScene);
    scene->addChild(layer);
    return scene;
}

bool SplashScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();    
	auto logo = Sprite::create("Logo.png");
	logo->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));	
	addChild(logo);
	scheduleOnce(schedule_selector(SplashScene::createNexteScene), 1);

    return true;
}

void SplashScene::createNexteScene(float dt)
{
	Scene* scene = nullptr;
	switch (_nextScene)
	{
	case SplashScene::GAME_SCENE:
		scene = GameScene::createScene();
		Director::getInstance()->replaceScene(TransitionFade::create(0.5, scene));
		break;
	case SplashScene::MENU_SCENE:
		break;
	default:
		break;
	}
	
}

Can anybody help me?

Do you have any derived class which override the onExit method but forget to call the base version of onExit?

You problem might be it.

1 Like

No, I donā€™t override the onExit method in any classes.
It looks like bug in cocos2d-x v3. I created a simple application, copied and pasted HelloWorldScene, renamed the class from HelloWorld to Temp and wrote

void HelloWorld::menuCloseCallback(Ref* pSender)
{
	auto scene = Temp::createScene();
	Director::getInstance()->replaceScene(TransitionFade::create(1, scene));
}

App crashes when I close it while transition is running.

when you say your app is crashedā€¦ please explain in detail what happenedā€¦

or bestā€¦ just save your logcat to a text fileā€¦ and put it in hereā€¦
so that we can reviewā€¦ where exactly the crash occouredā€¦ :smile:

Happy Coding. :smile:

When app crashes - it crashes

on the line CCNode::189

I attach log and source code (zip).

Ready for GLSL
Ready for OpenGL 2.0

{
	gl.version: 4.2.0 - Build 10.18.10.3355
	gl.supports_NPOT: true
	cocos2d.x.version: cocos2d-x 3.2
	cocos2d.x.compiled_with_profiler: false
	cocos2d.x.build_type: DEBUG
	cocos2d.x.compiled_with_gl_state_cache: true
	gl.max_texture_size: 16384
	gl.vendor: Intel
	gl.renderer: Intel(R) HD Graphics 4600
	gl.max_texture_units: 96
	gl.supports_ETC1: false
	gl.supports_S3TC: true
	gl.supports_ATITC: false
	gl.supports_PVRTC: false
	gl.supports_BGRA8888: false
	gl.supports_discard_framebuffer: false
	gl.supports_vertex_array_object: true
}


Assert failed: Node still marked as running on node destruction! Was base class onExit() called in derived class onExit() implementations?
Assertion failed!

Program: ...s2dx\projects\Temp\proj.win32\Debug.win32\Temp.exe
File: CCNode.cpp
Line: 189

Expression: !_running

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

Classes.zip (4.4 KB)

I have tested your code with the v3.3 on my MacbookPro, itā€™s OK.
Whatā€™s the engine version do you use?

I use cocos2d-x v3.2 on Windows 8.1 Proffesional with MS Visual Studio 2013.
I have recorded video with crash application. (Sorry for *.wmv in *.zip - I donā€™t know the best way to attach the video).
cocos2d-x v3 bug.zip (493.4 KB)

On the video I run the app => press button => start replace scene with Transition => close the app => see the crash.

I have same similar problem.

I made a class that inherits from TableViewCell. I added my custom cell to a table which is in a scene. When I call replaceScene I get same error. It only happens on iOS 7.1. It doesnā€™t happen on iOS 8 either on android devices.

I use cocos2d-x 3.3.

Yeah, I met this too.

Cocos2d-x 3.3 with lua.

Just called a ā€œreplaceSceneā€, and it said ā€œNode still marked as running on node destruction! Was base class onExit() called in derived class onExit() implementations?ā€

I didnā€™t do any ā€œonEnterā€ nor ā€œonExitā€

I had this same problem also using cocos2dx 3.3, does the cocos2dx team have solution for this?

Same thing on Win32 (v3.4). Run cpp-test go to transition menu, click on next transition and try closing application while transitioning scene (ALT+F4 or clicking on ā€˜xā€™) => crash.

I got this now. I am moving a game made in cocos2d-x 3.5 to 3.6ā€¦ and just like that the problem appeared. I have seen this before, afair, but it was never a problem. Iā€™m not sure what changed, except 3.5->3.6.

I do not override onExit in any class. I do override onExitTransitionDidStart, but I always and double-checked that super class implementation is called. And, this problem did not appear like this on 3.5ā€¦

I would like to know if thereā€™s a way to know WHAT node was not properly removedā€¦ this is not in the debug log.

Right now Iā€™m using RapidGame so I canā€™t easily dig into cocos2d-x code :stuck_out_tongue:

Iā€™m getting this problem with any Director::getInstance()->replaceScene(scene) call.

I seem to have find a cure for my problems. As I use RapidGame, I looked to the template game project of RapidGame to see how transitions are performed there. Turns out the structure of scenes are quite different from what Iā€™ve been used until now in cocos2d-x.

Instead of subclassing Layer for a scene, the template subclasses Scene. No use of init(), createScene() etc. Just use new Mysceneclass when instantiating a scene. I donā€™t know where this kind of code came from because it does not look like itā€™s made its way into the sample HelloCpp in cocos2d-x 3.6 yet. Things are a bit confusingā€¦ but it looks like I fixed this issue for now.

Ok Iā€™m back with thisā€¦ because using new Myscene seems to likely cause memory leaks, because the scenes replaced when using replaceScene() arenā€™t ever deleted, obviously, because in C++ that would be the responsibility of the caller of newā€¦ or so my thinking goes. So I am reverting the code to use createScene, but that brings back the crashing when going to next scene. Dohā€¦

Iā€™m also dealing with this issue, has anyone figured out a solution? Mine is Director::popScene().

This seems to still be an issue in 3.10.
Quitting the app while replacing scene using a transition makes a base call to

TransitionScene::~TransitionScene()
{
    CC_SAFE_RELEASE(_inScene);
    CC_SAFE_RELEASE(_outScene);
}

which attempts to release scenes that are being transitioned between resulting in the assertion of

Node still marked as running on node destruction! Was base class onExit() called in derived class onExit() implementations?
1 Like

The reason is you replaced the scene even before your first scene is finished creating. Example !

You have 3 scene : A , B , C.

At scene A , you call :
Director::getInstance()->replaceScene(B::createScene());

At scene B, you call :
Director::getInstance()->replaceScene(C::createScene());

For some reason , Scene B quickly call scene C -> The Scene B promptly uninitialized -> crash !

I confirm that this still happens with cocos 3.17 beta (from github).

i am having same problemā€¦ did you get the solution :slight_smile:

yes, some codes was wrong , so you need to 2xcheck codes in scenes. Or you can add loading scene , when you want to change scene.