cocos-engine
cocos-engine copied to clipboard
How do we recongnize CCONB files
Currently we deserialize certain sorts of asset into CCON binary format then store them as .cconb
files. Some users claim that their target platform/CDN doesn't allow such extension of file to be loaded or gzip-ed. We have several ways to solve this problem.
The widely-used binary format has extension .bin
. But if we deploy CCON binary in .bin
, we need to distinguish CCON binary from plain binary from user domain. In the following I posted some distinguishing method.
Treat all .bin as CCON binary
We could treat all .bin
as CCON binary file. For user's plain binaries, we import them as BufferAsset
which then would be serialized into CCON binary file.
Pros
-
Easy to implement.
-
Could distinguish accurately.
Cons
-
Users have to use asset loading methods to load their binaries.
❓ I don't think this causes actual problems indeed.
Constuct a CCON table
We could contruct a CCON table to indicates what .bin
are CCON or plain binary.
Pros
-
Easy to implement.
-
Could distinguish accurately.
Cons
- Extra memory/storage required.
Guess file format from file content
CCON binary data has leading bytes(the ASCII of CCON
chars). We could guess the format according to this.
Pros
- Easy to implement.
Cons
- Could not distinguish accurately. There're potential problems.
Let CCON file format be well-known
Platform limits base on they don't know such application-specific file format and extension. We could drive platforms to recongnize this format. Specifically, we should:
-
Register CCON media type in https://www.iana.org/assignments/media-types/media-types.xhtml
-
Contact our target platform vendors and request a by-pass policy on CCON files.
-
If the application is targetting C/S and the server side is configurable by users. Teach users to configure the media type.
Pros
-
We need change nothing.
-
Extend Cocos Creator ecosystem.
Cons
- A slow remedy cannot meet an urgency.
Related:
- https://forum.cocos.org/t/topic/97736/41
麻烦把工作量评一下级,在 2 进制序列化方案订下来之前,我倾向于选择工作量最小的方案,改得越多,之后给后面的负担越大
@holycanvas Please use English
@dumganhar is refactoring the whole serialization system, and this problem will be solved after that
Another solution:
Compress the .cconb file in building stage, decompress it in runtime. Maybe LZ4
is a choice.
Pros
- Don't need to rename .cconb to .bin
- Don't need to ask the target platform or CDN to recognize .cconb extension
Cons
- Impact runtime performance, especially LZ4 decompress in JS may be slow. Need to do some performance tests.