Android drawcall和framerate异常

我写了一个demo,里面使用了batch,测试的时候发现在安卓系统的不同浏览器里表现相差巨大。
机器是node2,安卓版本4.1.2,另外我用这个页面测试过浏览器是否支持webgl:http://get.webgl.org/。

在原生浏览器上的drawcall是3,符合预期,我一共用了3个batch对象,帧率60(这是唯一一个符合预期的测试环境),支持webgl;
在chrome上测试drawcall是22,帧率30,不支持webgl;
在uc web和qq浏览器上测试drawcall是3,但是帧率只有15以下,支持webgl;
在微信里测试,drawcall超过了100,应该是完全没有批处理,但是帧率能达到40.

我想请教下为什么同一个机器,不同浏览器上drawcall数量和帧率会差别这么大,该如何去优化,谢谢

I don’t know which way is best performance wise across all browsers, because every browser has a different render engine and script engine, so the frame rate is different too.

thx for your reply.
我想在国内cocos2d游戏要商业化的话,至少要支持safari、安卓原生浏览器、UC、还有微信、微博等接入端,不要求性能很高,但是简单场景24帧个人认为是基本需求。
我其实比较关注cocos2d-html5的canvas实现,webgl的兼容性会比较远,我看到有简短的关于cocos2d-html5 dirtyregion的介绍,但是没有再多的资料,不知道这是canvas渲染状态下默认开启的还是需要开发者手动开启,在微信里,100个渲染对象帧率还能达到40,是否dirtyregion生效了呢。

另外我也看到关于canvas缓存的简短介绍,我的游戏里有很多静态的区域,缓存能带来不错的优化效果,可是我不知道如何使用缓存,或者如何让底层更好地缓存。
cocos2d-html5相关的资源实在太少了

Thanks for your advice. We are focusing on Chrome mobile, android native browsers (android 4.0+), safari, Opera, UC, QQ browsers and wechat.

We will try our best to make games run more smooth in these browsers. However, it is a big job for us, we are putting all our energy on it.

It is so appreciated if someone could help us to check the performance on these browsers, and send us some suggestion.

多谢回复。
今天又发现一个性能问题,不知道是不是我用的不对。
我将游戏demo的整个场景(是一个Layer对象,渲染方式是canvas)旋转90度或者缩放之后,整个游戏的帧率从60掉到了20以下,从过去开发引擎的经验来看,旋转和缩放并没有带来多少额外的性能开销,所以这个现象有点出乎意料。另外我用这个方法来做自适应也同样导致帧率出现相同的现象:
cc.EGLView.getInstance().setDesignResolutionSize(775, 500,cc.RESOLUTION_POLICY.SHOW_ALL);
如果我需要旋转整个场景或者缩放场景来适应屏幕,我该怎么做呢。

ps:我用上述函数来做自适应屏幕,在UC浏览器里不兼容。

Shun Lin wrote:

Thanks for your advice. We are focusing on Chrome mobile, android native browsers (android 4.0+), safari, Opera, UC, QQ browsers and wechat.
>
We will try our best to make games run more smooth in these browsers. However, it is a big job for us, we are putting all our energy on it.
>
It is so appreciated if someone could help us to check the performance on these browsers, and send us some suggestion.

多谢回复。
今天又发现一个性能问题,不知道是不是我用的不对。
我将游戏demo的整个场景(是一个Layer对象,渲染方式是canvas)旋转90度或者缩放之后,整个游戏的帧率从60掉到了20以下,从过去开发引擎的经验来看,旋转和缩放并没有带来多少额外的性能开销,所以这个现象有点出乎意料。另外我用这个方法来做自适应也同样导致帧率出现相同的现象:
cc.EGLView.getInstance().setDesignResolutionSize(775, 500,cc.RESOLUTION_POLICY.SHOW_ALL);
如果我需要旋转整个场景或者缩放场景来适应屏幕,我该怎么做呢。

ps:我用上述函数来做自适应屏幕,在UC浏览器里不兼容。

hello, English language must be used on the forums, this message could be removed…

sorry, I don’t konw the rule of the forums before, my English is poor, it’s hard for me to tell the question in English.

when I use the function “cc.EGLView.getInstance().setDesignResolutionSize” my game demo, the framerate falls from 60 to 20.
I test it in a few browsers, similarly, who can tell me the problems, thx.

I have detected dramatic performance losses by using simple things like setPosition(Y) in a CCSprite. When you do that, the “setDirty” function is called, and a lot of calculations are processed, if you have a few sprites… the mobile browsers can’t handle that.

In regards to the setDesignResolutionSize, it’s something mandatory in the cocos2d architecture. What size are you setting? maybe the problem is you are setting a big size

I found performance losses by using setScale & setRotation in a Layer,but I only use once in initializing, the ditry flag is removed after the next reder process, why should the framerate fall down last for the running time.
I set the size to 1280*768 to adapt my screen。
However, if I scale the view to big size in the broswer by hand, I doesn’t impact the framerate.

万里独行 万里 wrote:

I found performance losses by using setScale & setRotation in a Layer,but I only use once in initializing, the ditry flag is removed after the next reder process, why should the framerate fall down last for the running time.
I set the size to 1280*768 to adapt my screen。
However, if I scale the view to big size in the broswer by hand, I doesn’t impact the framerate.

fix it, “next reder” -> “next render”

It may not be problem of cocos2d, I use these code in my demo:

var canvas = document.getElementById(“gameCanvas”);
canvas.getContext(“2d”).scale(1.4, 1.6);

And then the framerate also falls, from 60 to 26.

the “setDesignResolutionSize” of cocos2d uses the scale function above, it’s the major factor in bad performance, but how could I scale my game for multi resolution?

in cocos2d you have to use setDesignResolutionSize…

I’m also experiencing a lot of performance problems on mobile browsers. I’m not sure if cocos2d-html5 is mature enough to be used in commercial projects (maybe for js-bindings, but not for mobile browsers), but is just my opinion, I’m more experienced with cocos2dx c++, what is great, and I might be doing something wrong on html5

In many forums, I read that having two (or more canvas) could increase performance. For instance, you have a canvas for the background, that never changes, so you avoid to have to redraw a big texture at every frame. But I think cocos2d-html5 is not ready to use multiple canvas