Skip to content

Commit

Permalink
HTML5 issues; wasm filename, slow loading
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Poobslag committed Jun 21, 2020
1 parent 3484ce6 commit 7c85176
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion export_presets.cfg.template
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
8 changes: 6 additions & 2 deletions src/main/resource-cache.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7c85176

Please sign in to comment.