[HTML5] Reducing number of HTTP Get Requests on load? [SOLVED]

ccoddes

  • Posts: 4
Hi,

I'm revisiting my old Stencyl game which was previously exported in Flash. Currently I'm trying to reexport it into HTML5. What I do is to unzip the .zip file and host the contents on a webserver, but what I noticed is that there are a lot of HTTP GET Requests to individual assets used in the game during Loading (when the game is first accessed)

Although I'm new to HTML5 game creation, this doesn't seem optimal to me as a lot of HTTP GET Requests sounds like it slows down the load time of the game. I was was wondering if there is a way to "bundle" the assets together, so we use fewer requests to retrieve a "bundled" pack of assets and extract the assets once we get them on the client.

I also saw this forum post http://community.stencyl.com/index.php?topic=59252.0 which seems to be saying that HTML5 game assets can be in a .pak format. This seems like what I want but I didn't manage to find a way to do so through the Stencyl editor.

Has anyone else encountered this problem, or knows a solution to this? Thanks!

« Last Edit: March 03, 2021, 07:38:44 pm by ccoddes »

Luyren

  • *
  • Posts: 2735
As per that thread, it seems Stencyl already bundles the assets in the .pak format, considering that thread is from late 2019, and the most recent public version of Stencyl was released late 2020. My blind and uneducated guess is that the fact you are unzipping the game export on your end is or the way you are hosting it is affecting the number of web requests. Most users publish their games on sites like itch.io, so I'd guess few experience what you encountered. I could be wrong on all accounts here though.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Justin

  • *
  • Posts: 4644
Publishing to html5 packs the assets by default, but only with the new 4.1.0 features, which aren't available in the public releases.

To do this yourself in the latest public version of Stencyl, add this to "Settings > Advanced > OpenFL Settings". You can replace gzip with pak if you want.

Code: [Select]
<section if="html5">
<library name="default" type="gzip" if="publishing" />
</section>

I don't recall off-hand if that's expected to work with no other changes. If it doesn't work just like that, you'll either want to subscribe for access to the private builds, or just wait for the public release of 4.1.0.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

ccoddes

  • Posts: 4
Thanks for the fast replies!

You're right, I'm currently on the public release 4.0.4. As suggested above, I tried adding
Code: [Select]
<section if="html5">
    <library name="default" type="gzip" if="publishing" />
</section>
to the settings but it didn't work out of the box, resulting in this error at the bottom of the log:

Code: [Select]
C:\Users\CJ\AppData\Roaming\Stencyl\stencylworks\games-generated\Chomper\Export\html5\bin\index.html
2021-03-03 11:27:38,661 DEBUG [pool-1-thread-5] stencyl.sw.util.FileHelper: Trying to delete file that does not exist: C:\Users\CJ\AppData\Roaming\Stencyl\stencylworks\games-generated\Chomper\Export\html5\bin\config
2021-03-03 11:27:38,661 DEBUG [pool-1-thread-5] stencyl.sw.util.Util: Running command: [C:\Program Files\Stencyl\plaf\haxe-bin\windows64\haxelib.exe, run, openfl, -verbose, build, -debug, project.xml, html5, -minify]
2021-03-03 11:27:39,246 INFO  [Thread-46] stencyl.sw.util.StreamGobbler: [haxelib.exe] OpenFL Command-Line Tools (8.9.5-Lpv3od)
2021-03-03 11:27:39,246 INFO  [Thread-46] stencyl.sw.util.StreamGobbler: [haxelib.exe] Initializing project...
2021-03-03 11:27:39,246 INFO  [Thread-46] stencyl.sw.util.StreamGobbler: [haxelib.exe] Using project file: project.xml
2021-03-03 11:27:39,246 INFO  [Thread-46] stencyl.sw.util.StreamGobbler: [haxelib.exe] Reading Lime config: C:\Users\CJ\AppData\Roaming\Stencyl\stencylworks\prefs/.lime_config.xml
2021-03-03 11:27:39,999 INFO  [Thread-46] stencyl.sw.util.StreamGobbler: [haxelib.exe] Running command: UPDATE
2021-03-03 11:27:40,000 DEBUG [Thread-46] stencyl.sw.util.StreamGobbler: [haxelib.exe]  - Creating directory: Export/html5/obj/libraries
2021-03-03 11:27:40,857 DEBUG [Thread-46] stencyl.sw.util.StreamGobbler: [haxelib.exe]  - Copying file: Assets/data/game.mbs -> Export/html5/bin/
2021-03-03 11:27:40,859 ERROR [Thread-46] stencyl.sw.util.dg.MessageDialog: Encountered errors while building your game.: Check your logs and post them to the forums.  - Please describe what you have been doing. Be as specific as possible. Your game could not be written, because the destination file appears to be in use. Make sure you have closed all previous instances of your game, and use Run -> Clean Project.
2021-03-03 11:27:40,909 DEBUG [pool-1-thread-5] stencyl.sw.util.Util: Process 'haxelib.exe' exited with code: 1

Good to know that it will be supported in the future, however! If I may ask, is there an estimated time for the next public release?

Justin

  • *
  • Posts: 4644
You may be able to build successfully if you delete C:\Users\CJ\AppData\Roaming\Stencyl\stencylworks\games-generated\Chomper\Export\html5 first. If that works, you'll probably need to do so before every time you publish with those settings.

Hard to estimate when the next public release will be, unfortunately. It's in the midst of some pretty significant changes.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

ccoddes

  • Posts: 4
Thanks Justin, that workaround to delete the html5 folder solves the building issue. I do have to delete the folder every time I build but its workable for now :) It seems like the assets are now packed except the sfx and music ones (is this expected?)

Appreciate the help!!