Hi,
In our game we have big skeleton and atlas files and we were noticing a big performance issue running Spine on old devices. After profiling the code, I noticed that the major problem was the loading time of the skeleton and atlas files of some complex objects. In our case, our main spine object was taking 5.8 seconds just to load on a iPad mini, without any texture.
After profiling, I came up to the following conclusions:
- The JSON parser used by Spine is very slow
- The JSON format itself is very slow for big skeletons
- The Atlas file format used by Spine is also very slow
In order to solve these issues, I created 2 projects that can be found on the following repos:
https://github.com/atdrez/opack
https://github.com/atdrez/sharpjson
OPack is a binary format that is fully compatible with JSON. It's optimized to avoid key/value duplications which drastically reduces the size of the file and load time. It can reduce more than 3x the original file size (in our case, the biggest JSON stripped had 1.4mb, it reduced to 397kb). It's also much more faster then other binary JSON formats like BSON and UBJSON.
It runs roughly 5x faster than the original Spine Json parser, which reduced drastically the loading time of our application.
SharpJSON is a standard Json parser but 2x faster than the current JSON Parser used by Spine.
Here are some benchmarks (tested on a MacBookPro 2.9 GHz Intel Core i5, 8GB Ram) using one of our biggest skeleton data. It shows the decoding time for each parser (looped in 5 steps):
OPack: 474ms
SharpJson: 1257 ms
JsonSpine: 2525ms
Kernys.BSON: 2480
MiniJSON: 3043ms
PatrickVanBerguer's JSON: 3591ms
In order to integrate both with Spine is fairly easy; it's just a few lines of code.
It would be great if these optimizations goes to upstream. Let me know if I can be of any help.
Best regards,
Adriano Rezende