Some questions about using JavaScript (and Cocos Creator) on iOS

Hi, I have some questions about using JavaScript (and Cocos Creator) on iOS.

  1. It seems to offer “hot update” of JavaScript code via cc.sys.cleanScript and cc.game.restart, but isn’t it against Apple’s rule of prohibiting interpreters in apps?

  2. As I understand it JIT is disabled on iOS for SpiderMonkey, but how slow is it compared to Android on a similar-spec iOS device?

  3. Commenting out unused modules in
    https://github.com/cocos2d/cocos2d-x/blob/v3/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp
    helps to reduce the binary size, but how much? According to
    https://github.com/chukong/cocos-docs/blob/v3-unified-documentation/manual/framework/html5/release-notes/v3.2rc0/upgrade-guide/en.md
    the minimum size for Android is 4.4MB, but how large is it on iOS? (In other words, how bloated is it compared to a C++ project on iOS?)

  4. In
    https://github.com/cocos2d/cocos2d-x/blob/v3/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp
    there are lines

         // ui can be commented out to reduce the package, attention studio need ui module
         sc->addRegisterCallback(register_all_cocos2dx_ui);
         sc->addRegisterCallback(register_all_cocos2dx_ui_manual);
    

but do they affect Cocos Creator if commented out?

2 Likes

Hi @ryukbk, @slackmoehrle, @pandamicro @nantas2

Could someone from the engineering team please be so kind in feedback concerning the above post, especially # 1, # 2 as it pertains to developers using Cocos Creator / Javascript. Would really appreciate feedback concerning the above questions.…Thanks and God Bless…

Sincerely,

Sunday

@luke2125 Just FYI, most, if not all, of our team observes the weekend. The original post is at most 1 day old with your post for answers coming just 4 hours after it was posted. I’ll ask a member of our engineering team to have a look at this.

Hi @slackmoehrle

Ok, no problem…However, if you look at my response, I’m not requesting feedback immediately, I’m using the word please, be so kind to provide feedback… And that’s why I included the engineering team with my post, cause the original post by @ryukbk didn’t include engineering team…Now, since we are in the business of FYI, here’s some FYI for you:

http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/execution-order/

http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/pooling/

http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/modular-script/

http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/web-debug-scripts/

http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/

Now, the question is when will the above be complete? Is there a timetable for the above to be complete? Does it go along with Cocos Creator roadmap…? The reason I ask, is that my game is 90% done, and I’m still waiting for the Physics Engine to be implemented, which hopefully will be **now in **11/2016… but would really like to double check my game (code) with the above content…

Thank you…have a nice day…God Bless…

Sincerely,

Sunday

Yes, it agianst. But everyone in China is using “hot update” via cocos2d-x lua / javascript, game companies even added Lua binding to Unity just to hot update their games. Apple tacitly approve these, including the #1 and #2 top grossing games, which are powered by cocos2d-x. The benefit is: you can update your game every week, even every day. I think the bottom line of Apple is: DON’T BE EVIL.

Yes it’s a bit slower, comparing to WKWebView. But it’s totally OK to make complicated games like MMO. We even created MMO games in pure HTML5, so it’s not a problem in SpiderMonkey JSB solution.

The engineer team can ask the rest questions.

@luke2125 I guess one can never convey tone via forums, but I did not take what you wrote as bad, just hasty.

I’ll check these docs to see if content has been added and not yet deployed.

What we offer is a mechanism to restart the engine, a system to download files from the server and FileUtils which can read local files instead of package files. None of these are forbidden by Apple, but if you use these system to download new file that changes your app massively or add a great amount of new content, these are violating Apple’s policy. So hot update is for small updates on iOS.

Yes, it’s disabled, but sorry I don’t have a concrete comparison result.

For one architecture it’s similar to Android, but iOS need a fat package which contains two architectures armv7 and arm64. So in global it will be two times larger than Android package.

We indeed use some of the types in UI package, like EditBox, VideoPlayer and WebView.

Thank you for answers!
Well if Cocos Creator can be used just to create scene layout we can omit JavaScript use, but apparently it’s not on the roadmap, it’s a really hard decision for us to use JavaScript instead of C++ in an existing app to use the latest version of Cocos2d-x and Cocos Creator.

Ahm, I think you can use Cocos Creator just to create the scene layout, but you’ll have to write your own C++ parser and loader for the resulting resources.

That’s theoretically possible, but I assume it would be hard because we don’t have a public data structure documentation, and I don’t think for the current stage it’s stable enough.

Anyway, @ryukbk you mentioned that you can’t decide to use JS instead of C++ in an existing app, but why do such a fundamental change in a mature project ? We actually suggest that users transfer to Creator with a new project or some prototyping tasks. There is indeed a big gap between Cocos2d-x and Cocos Creator, won’t be easy to transform one to another.

@pandamicro For example, you have an existing app with UI elements developed with Cocos Studio. Now, if you try to update the Cocos2d-x version to the latest one, Cocos Studio support is already broken in 3.12 according to


The poor support of Cocos Studio makes it mandatory to port Cocos Studio-developed parts to Cocos Creator (and JavaScript). The latest version of Cocos2d-x contains bug fixes and things related to newer OSes, backporting them by ourselves is not an option due to the cost.

Now I understand, thanks for the clarification and we are truly sorry for the inconvenient, I will report this to our team leader @ShunLin . For your case, there are two possibilities:

  1. we do provide the cocos studio importer to migrate to Creator, but it’s not free, the code need to be reorganized and rewrote.
  2. You can also stay in v3.11, and manually merge the bug fixes in new versions, bug fixes can be found in our github pull requests.

@pandamicro
I tried to import a Cocos Studio project with Cocos Creator 1.2.1-rc.1 and got

TypeError: r is not a function
at /Applications/CocosCreator.app/Contents/Resources/app.asar/editor/builtin/project-importer/core/studio/csd-importer.js:1:20956
at CCLoader.<anonymous> (/Applications/CocosCreator.app/Contents/Resources/engine/cocos2d/core/platform/CCAssetLibrary.js:99:17)
at /Applications/CocosCreator.app/Contents/Resources/engine/cocos2d/core/load-pipeline/CCLoader.js:200:42
at /Applications/CocosCreator.app/Contents/Resources/engine/cocos2d/core/platform/utils.js:38:21
at _combinedTickCallback (internal/process/next_tick.js:67:7)at process._tickCallback (internal/process/next_tick.js:98:9)
at EventEmitter.o (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/builtin/project-importer/main.js:1:206)at EventEmitter.g (events.js:286:16)
at emitTwo (events.js:106:13)at EventEmitter.emit (events.js:191:7)
at EventEmitter.<anonymous> (/Applications/CocosCreator.app/Contents/Resources/electron.asar/browser/api/web-contents.js:128:18)
at emitTwo (events.js:106:13)at EventEmitter.emit (events.js:191:7)  TypeError: r is not a functionat /Applications/CocosCreator.app/Contents/Resources/app.asar/editor/builtin/project-importer/core/studio/csd-importer.js:1:20956
at CCLoader.<anonymous> (/Applications/CocosCreator.app/Contents/Resources/engine/cocos2d/core/platform/CCAssetLibrary.js:99:17)
at /Applications/CocosCreator.app/Contents/Resources/engine/cocos2d/core/load-pipeline/CCLoader.js:200:42
at /Applications/CocosCreator.app/Contents/Resources/engine/cocos2d/core/platform/utils.js:38:21at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at EventEmitter.o (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/builtin/project-importer/main.js:1:206)at EventEmitter.g (events.js:286:16)
at emitTwo (events.js:106:13)at EventEmitter.emit (events.js:191:7)
at EventEmitter.<anonymous> (/Applications/CocosCreator.app/Contents/Resources/electron.asar/browser/api/web-contents.js:128:18)
at emitTwo (events.js:106:13)at EventEmitter.emit (events.js:191:7)  

Where is the right place to report the issues of the CSD importer of Cocos Creator?
I see https://github.com/cocos-creator/engine/issues but is there any other place?
It seems the contents of app.asar (editor) are not on the github and I can’t find csd-importer.js online.

You can report this in Cocos Creator sub forum, and @zhangbin is the right person to get in touch with.

Currently we are in holidays in China, and our city is suffering a typhoon, so maybe he can only respond in next week, if we missed your post, please do add some comments to pop it up next week.

We are not using the issue tracker of engine repo, the issue tracker is currently private.

Thank you, for reference the Cocos Creator issue is now discussed in