From 7c85176b33ec349924d4374f5c76a0a24e3c2512 Mon Sep 17 00:00:00 2001 From: Poobslag Date: Sun, 21 Jun 2020 17:35:13 -0400 Subject: [PATCH] HTML5 issues; wasm filename, slow loading The HTML5 export was looking for 'v0.wasm' instead of 'v0.0621.wasm'. Additionally itch.io wants the html file named 'index.html'. I've just renamed the file to 'turbofat.html' for now, and the extra rename is a manual step. The HTML5 export was taking about 5 seconds to load, because it was only loading one resource every frame. I've changed it to load as many resources as it can in 0.1 seconds, as a compromise between speed and responsiveness. --- export_presets.cfg.template | 2 +- src/main/resource-cache.gd | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/export_presets.cfg.template b/export_presets.cfg.template index 7b02a23d3..c7fd337d1 100644 --- a/export_presets.cfg.template +++ b/export_presets.cfg.template @@ -109,7 +109,7 @@ custom_features="" export_filter="all_resources" include_filter="*.json" exclude_filter="src/test/*, src/demo/*, assets/test/*, assets/demo/*" -export_path="export/html5/turbofat-html5-v##VERSION##.html" +export_path="export/html5/turbofat.html" patch_list=PoolStringArray( ) script_export_mode=1 script_encryption_key="" diff --git a/src/main/resource-cache.gd b/src/main/resource-cache.gd index 700d5636d..260b7f492 100644 --- a/src/main/resource-cache.gd +++ b/src/main/resource-cache.gd @@ -14,6 +14,8 @@ signal finished_loading # number of threads to launch; 1 is slower, but more than 4 doesn't seem to help const THREAD_COUNT := 4 +const CHUNK_SECONDS := 0.1 + # enables logging paths and durations for loaded resources export (bool) var _verbose := false @@ -63,8 +65,10 @@ func start_load() -> void: func _process(delta: float) -> void: if OS.has_feature("web") and _remaining_resource_paths: - # Web targets do not support background threads, so we load resources one at a time - _preload_next_png() + var start_usec := OS.get_ticks_usec() + # Web targets do not support background threads, so we load a few resources every frame + while _remaining_resource_paths and OS.get_ticks_usec() < start_usec + 1000000 * CHUNK_SECONDS: + _preload_next_png() func _exit_tree() -> void: