hughbagan / wfc-roguelike

webgame using wave function collapse
1 stars 0 forks source link

HTML Version soft-locks when reaching level 10 #2

Closed VeryPuzzling closed 1 month ago

VeryPuzzling commented 1 month ago

HTML Version soft-locks when reaching level 10

Versions tested on: HTML (v3.5.3.stable.mono.official)

Steps to reproduce:

  1. Play the game
  2. Reach level 9
  3. Go up the stairs to go to level 10
  4. Soft-lock

Spotted by Feztek: https://itch.io/post/10080265

VeryPuzzling commented 1 month ago

It seems like Level/GUI/RedRect isn't fading like it should

hughbagan commented 1 month ago

Thanks. Every 10th floor the level generator re-builds its generation rules based on the Sample tilemap. So it's likely to do with that. However, it already does this on the first floor right after the tutorial, so I'm not sure yet what changed.

I found this error in the browser console:

blood.js:369 exception thrown: RuntimeError: unreachable,RuntimeError: unreachable
    at GDMonoInternals::tie_managed_to_unmanaged(_MonoObject*, Object*) (wasm://wasm/063704a6:wasm-function[790]:0x3840c)
    at godot_icall_Node_Ctor(_MonoObject*) (wasm://wasm/063704a6:wasm-function[34924]:0x808ab2)
    at do_icall (wasm://wasm/063704a6:wasm-function[37161]:0x86eb21)
    at do_icall_wrapper (wasm://wasm/063704a6:wasm-function[10671]:0x201ecd)
    at interp_exec_method_full (wasm://wasm/063704a6:wasm-function[4644]:0xe2693)
    at mono_interp_newobj (wasm://wasm/063704a6:wasm-function[32921]:0x77cc9f)
    at interp_exec_method_full (wasm://wasm/063704a6:wasm-function[4644]:0xe7d97)
    at interp_runtime_invoke (wasm://wasm/063704a6:wasm-function[33866]:0x7b9e7c)
    at mono_jit_runtime_invoke (wasm://wasm/063704a6:wasm-function[32903]:0x77bf65)
    at do_runtime_invoke (wasm://wasm/063704a6:wasm-function[6707]:0x155494)
onPrintError @ blood.js:369
blood.js:9 Uncaught RuntimeError: unreachable
    at GDMonoInternals::tie_managed_to_unmanaged(html.itch.zone/html/10620910/_MonoObject*, Object*) (wasm://wasm/063704a6)
    at godot_icall_Node_Ctor(html.itch.zone/html/10620910/_MonoObject*) (wasm://wasm/063704a6)
    at do_icall (063704a6:0x86eb21)
    at do_icall_wrapper (063704a6:0x201ecd)
    at interp_exec_method_full (063704a6:0xe2693)
    at mono_interp_newobj (063704a6:0x77cc9f)
    at interp_exec_method_full (063704a6:0xe7d97)
    at interp_runtime_invoke (063704a6:0x7b9e7c)
    at mono_jit_runtime_invoke (063704a6:0x77bf65)
    at do_runtime_invoke (063704a6:0x155494)

When the game stutters because the generator is working, we get this message:

L: GC_MINOR: (Nursery full) time 1.73ms, stw 2.04ms promoted 37K major size: 1728K in use: 1143K los size: 0K in use: 0K

It needs to allocate more memory each time. Need to do research on what this means.

It's also possible that exporting to the web with the "Threads" Variant will help.

hughbagan commented 1 month ago

Related:

https://github.com/godotengine/godot/issues/61412
https://github.com/godotengine/godot/issues/34506
https://github.com/godotengine/godot/issues/58538
https://github.com/godotengine/godot/issues/12699

hughbagan commented 1 month ago

Turns out the web C# export is pretty borked: https://www.reddit.com/r/godot/comments/17h3c8o/what_is_the_best_way_to_export_to_web_right_now/

C# threads on the web are not currently supported in any version.

Re-writing the generator in GDscript might work... if it's fast enough.

hughbagan commented 1 month ago

On the road to re-writing the generator in GDscript. I'm converting the C# Tasks to GDScript Threads. However, it seems there's a flaw in the Godot debugger. If a thread encounters an error, it will fail silently and return in the same manner as if it successfully completed its function.

https://github.com/godotengine/godot/issues/18330
https://github.com/godotengine/godot/issues/51936

This is very dangerous, since the generator will fail silently and create bad output, yet still signal "done".
Note to self: start Godot from the command line when dealing with threads.

hughbagan commented 1 month ago

The generator has been rewritten with GDscript, which means we can use the "Threads" web export now and fix these lock-ups.
Branch generator-rewrite has been merged to master: https://github.com/hughbagan/wfc-roguelike/commit/57ba7db2010f584758d55378dea1125d83c1e9ce