C++ to Web = WebAssembly. Polling for feature request

It seems that there is Edge support:

Im on record as hoping for WA support

Potential benefits of WA:

  • one codebase that supports mobile, desktop, and web
  • the speed that comes from compiled code
  • access to c/c++ libraries

I think that if/when cocos2d-x starts adding more 3d support (and shouldnt we change the name to just cocos-X then?) that WA will start making more and more sense.

@SpecialWE

Yep - the message on DEMO page is “little” strange:

=========

Uh-oh! WebAssembly isn’t enabled in this browser. To get an early preview of this experimental technology, at your own risk:

  • on Chrome Canary, open chrome://flags/#enable-webassembly and enable the switch.
  • on Firefox Nightly, open about:config and set javascript.options.wasm to true.

See a preview of Microsoft Edge support and follow Safari support on WebKit’s feature status page.

But I think is just out of date.

I checked once again:
Firefox 50.0.2 (For macOS) - stable, not nightly build.
Worked - just need turn on “about:config javascript.options.wasm” flag.

Chrome 55.0.2883.75 (64-bit) (For macOS)
Worked - just need turn on “chrome://flags/#enable-webassembly” flag.

Yep - this is not all browsers - but the main is that all are working in this direction.

Any update?

Would like to upvote this feature request. Now that Chrome and Firefox have already gotten it live.

This would have to come from the community. There’s very little chance Chukong will work on this feature.
It’s probably smarter to replace the renderer with SDL or BGFX instead of trying to get the engine to compile.
If someone is already working on this with the latest 3.15 code revision that’d be great. It’s possible to get it compiling, but it may or may not take quite a bit of tedious work??

I keep looking into it, and simple OpenGL examples are easily ported to emscripten, but the cocos2d code base has a lot of extra libraries/frameworks that must support it.

Would love to hear of any progress, but I am not holding my breath. Prob smarter to move to Urho3D or other engine if it’s a feature you need. Or just port to cocos-js/creator :smiley:

Last week we tried WASM of cocos2d-x of a commit of this January. It works properly.

We are thinking of adding it back to main branch.

4 Likes

Yes @ShunLin that is great news :+1:

In a WASM capable browser does it perform better than the JS version?

Yep, i used PerformanceSpriteTest, WASM is about 50% quicker then cocos2d-html5, and takes less memory. But there is a problem that, all codes in a wasm file, and all resources in a data file which makes loading much slower than cocos2d-html5.

So not a complete win for WASM. There are always tradeoffs! Thanks @zhangxm

Now that WebAssembly support has been added to Safari, it appears that all the major browsers now support it.

I also want to upvote this feature request. My C++ App is available on all platforms except the web and too large already to be easily rewritten in Javascript. WebAssembly would be a major benefit for my App.

+1, this would be very helpful indeed

very welcomed feature…

@ShunLin so can we expect further work into it, On trello i don’t see any promising development efforts planned for c++ engine, would like to see if some one could clear a bit of air around c++ side.

Let’s add this please! I hate js :frowning:

2 Likes

It would be awesome! I think it is a must for this engine, it makes perfect sense.

1 Like

Any news and/or tips how to use cocos2d-x with webassembly?

1 Like

In this Thread
Answering the questions about Cocos Creator, the engine and editor

walzer (Cocos2d-x Founder) wrote:

Cocos Creator 1.6 is using WebAssembly to speed up some modules, e.g. physics. WebAssembly technology allows us to compile C++ framework onto WebGL, this is quite a good news. But it’s still in its early stage. Most of Android and iOS devices doesn’t support WebAssembly yet. Once it’s mature, we can avoid maintaining the JavaScript / C++ 2 framework, but merge into one. Currently my idea is to use C++/WebAssembly as the engine core, but still using JavaScript as the first-class API interface.

Are there any updates or further thoughts on this? Because this sounds promising having maybe C++ as the second “first-class” API interface?

I think as other engines (like Unity that compiles C# to WebAssembly) use WebAssembly it becomes a major technology in the web.