Cocos2d-x v4.0 Performance issue vs 3.17.1

See cocos2d-x v4.0 Performance issue on Android vs 3.17.1 · Issue #20668 · cocos2d/cocos2d-x · GitHub

fps is lower on iOS device, too

Anyone can help?

@slackmoehrle

Have you used a profiling tool to see where the differences are (in terms of memory, CPU and GPU usage etc.)? The profiling tool should also show you which sections of code are taking more time per frame.

Just a simple code like

auto scene = Scene::create();
auto layer = Layer::create();
layer->setPosition(Director::getInstance()->getVisibleOrigin());
scene->addChild(layer);

auto visibleSize = Director::getInstance()->getVisibleSize();

for (int i=0 ; i<3000 ; i++)
{
    Sprite *sprite = Sprite::createWithSpriteFrameName("test.png");
    sprite->setPosition(Vec2(random(0, (int)visibleSize.width), random(0, (int)visibleSize.height)));
    sprite->setScale(0.5);
    layer->addChild(sprite);

    Label *label = Label::createWithSystemFont(StringUtils::format("%d", i), "Arial", 15);
    sprite->addChild(label);
}

Director::getInstance()->runWithScene(scene);

v3 is much better than v4 ??

You still need to profile it to figure out exactly where the differences in performance is between v3 and v4. It may be the label code, or new rendering code etc., but no point guessing since profiling it will help narrow down the possible reasons.

Other than that, is this kind of test realistic though, and have you tried it without the labels?

When there are more draw calls, the performance difference will be greater

I found that v4 takes a lot more time in

Renderer::drawBatchedTriangles()

than v3

I believe the renderer is about 5% slower in v4 than v3.x IIRC. I don’t recall if that was just the simulator or on hardware also.

44 FPS V4 vs 60 FPS V3 (numbers from github issue)
It means that
V4 is ~ 27% slower
or
V3 is ~36% faster

@slackmoehrle is it possible to investigate this problem? For me it looks like significant regression.

We use hardware to test, so it’s a serious problem