Unnecessary increase files size for Playable ads

Hi, I’m trying to create my own tool based on the existing “playcanvas-rest-api-tools”.
My goal is to convert the default build of the PlayCanvas project to single-HTML, but with some difference from the standard “playcanvas-rest-api-tools”. I began to find out in what
order the whole app’s components are running and noticed the following thing:
in order for all assets to be used in one HTML, in the “config.json” file all urls must be converted into base64, thus increasing the size of all assets by 30%. After that we will have “config.json” inside with big strings instead of links, and the “files” folder can be deleted.
The next step we need to use “config.json” inside our HTML. In the “__start __. Js” file, this file is loaded using the “app.configure” function, which accepts the url. This means that we need to convert “config.json”, which already has heavy base64, into another base64, and these assets themselves increase by 30%.
In the end, instead of increasing each asset by 30%, we increase it by about 69%. This is a problem because in such apps (playable ads), the weight of the assets is critical. Also we need to keep in mind that the PlayCanvas engine itself takes up about 1.2 MB, and such an unnecessary increase in the size of all assets significantly reduces the ability to use PlayCanvas for this type of applications.
Maybe there are some ways to avoid this problem?
For example, if you allow the “app.configure” function to accept not only the url, but also a simple object, then we would only need to translate .json to the javascript object, without unnecessarily increasing the heavy file by 30%

That’s a good callout, I didn’t think about the extra data increase in base64’ing the config.json file and agree with your approach.

Looking at the app.configure function: engine/app-base.js at main · playcanvas/engine · GitHub

It would be simple to monkey patch in the tool to just take a JSON object.

I’ve created a ticket for this to look at when I next have time as it looks fairly small to do :slight_smile: : Patch app.configure to take a JSON object instead of URL to reduce total size · Issue #35 · playcanvas/playcanvas-rest-api-tools · GitHub

In the meantime, have you tried using the compression option for the engine?

It can save up to 500KB on the engine size :tada:

1 Like

Thanks for the answer.
Yeah, I have tried compression option, this is really nice and useful feature.
I will be very grateful if you let me know when this change in the engine will be released.

It won’t be in the engine but in the rest api tools instead as a patch. If you subscribe to the GitHub issue, you should be notified when it is closed and completed :slight_smile:

1 Like

Got it, thanks again

PR made for this with some numbers:

1 Like