Cocos Creator 2.x community fork - Cocos Enhance Kit v2.0 released, adding multi-threading support

Cocos Enhance Kit

This is a community fork of Cocos Creator v2.x, providing numerous new features, performance improvements and fixes.

We will continue to provide new features, optimizations and fixes while maintaining the principles of being fully open source and fully compatible.

We warmly welcome you to join us in improving this project!

Main Features

  • Full platform compatibility
  • Multi-texture rendering support
  • High-definition text rendering
  • Enhanced dynamic atlasing
  • Enhanced Label component performance
  • Enhanced Spine component performance
  • Support for Spine costume changes using SpriteFrame
  • Multi-threading support

For detailed descriptions, please visit our documentation. We won’t waste time elaborating on the updates here.

Updates

It’s been two years since the last feature update of Cocos Enhance Kit (not counting maintenance updates for engine version compatibility).
During these two years, Cocos Creator has upgraded from v3.6.0 to v3.8.4. While v3.x surpasses v2.x in most aspects, there’s been little change regarding the 2D performance issues that this project primarily addresses.
Therefore, besides existing v2.x projects, using this community fork for new 2D projects still offers performance advantages and is less troublesome.
Of course, if asked for a recommendation, we’d still suggest going with v3.x directly.
Returning to this v2.0.0 update, besides compatibility with the latest v2.4.13 engine version and various fixes, we’ve also experimented with multi-threading support for the engine on the WeChat mini-game platform.
Since our company still maintains projects using v2.x, during a recent performance analysis, we discovered significant time consumption in wx API calls on WeChat mini-games.
For example, WeChat’s network and file system interfaces, despite being asynchronous, were expected to have low latency. However, performance analysis on low-end devices showed each call taking around 3-6ms! Consider that the total rendering main loop time averages only about 9ms.
This causes stuttering even during resource preloading, so we needed to find ways to reduce this overhead.
After extensive research, we found that while WeChat mini-game platform documentation states that Workers don’t support any wx interfaces, a WeChat base library update announcement mentioned Worker support for file system, network, and audio interfaces.
After continuous communication with WeChat official staff and hands-on testing, we reached these conclusions:

  • On Android systems, Workers function as announced, supporting all three interfaces and even SharedArrayBuffer!
  • On Windows, Mac, and iOS systems, Workers still have issues - only the file system interface works normally, while other interfaces exist but don’t respond to calls.
    Since WeChat mini-game platform now supports these crucial interfaces, we decided to utilize them for a multi-threading overhaul of the engine.
    We first tackled the engine’s resource pipeline, moving download and caching operations to Worker threads, with results shown below:


As you can see, the performance overhead from file download interface calls (shown in red boxes) has disappeared. In the optimized resource loading process, only resource parsing occupies the main thread.
We attempted to move resource parsing to Worker threads as well but temporarily abandoned this due to thread communication overhead.
Now, we’ve integrated this optimization into Enhance Kit. Welcome to try it out and share your feedback.

Demo

Web Desktop
Web Mobile (Please use landscape orientation)

Links

Official Website
Documentation
Github
Sponsorship/extension

Support Us

Developing the community version requires substantial work, and your support is our greatest motivation:

  • Please give our project repository a Star!
  • Support us by purchasing our optional one-click installation extension!
1 Like