EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
989 stars 185 forks source link

Async_handler crashes when Internet disconnects or connection times out #3239

Open ghost opened 3 months ago

ghost commented 3 months ago

download_failure_retry of emscripten_async_wget2 may not callback due to timeout. And, if the resource loading fails, it cause the Player to crash.

Switching to offline during throttling will result in the following:

index.js:8546 
 GET http://127.0.0.1:8081/ep/games/2kki/Sound/door-hikido.wav net::ERR_INTERNET_DISCONNECTED
index.js:1132 Loading of Map Map0003.lmu failed.
The map was not found.

index.js:52 program exited (with status: 1), but keepRuntimeAlive() is set (counter=3) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)

index.js:175 Uncaught 
RuntimeError: memory access out of bounds
    at index.wasm.Player::UpdateInput(:8081/ep/EasyRPG-Mul…ve/build/index.wasm)
    at index.wasm.Player::MainLoop(:8081/ep/EasyRPG-Mul…ve/build/index.wasm)
    at index.wasm.main_loop(:8081/ep/EasyRPG-Mul…ve/build/index.wasm)
    at callUserCallback (index.js:7136:9)
    at Object.runIter (index.js:7211:11)
    at Browser_mainLoop_runner (index.js:7097:26)

And timeouts are difficult to reproduce. There is a chance of encountering net::ERR_TIMED_OUT (I'm not sure if it's spelled correctly) when the internet speed is extremely slow, which may result in neither download_success_retry nor download_failure_retry being called.

I want to ensure a callback by using emscripten_set_timeout. And add an overlay to display loading status and downloading progress instead of just showing a black screen.

ghost commented 3 months ago

I have fixed the issue. However, more testing is needed to determine if it has truly been fixed.

See: https://github.com/monokotech/EasyRPG-Multiplayer-Native/commit/03f8e739be4fce49be7bc2f15eee45a2ea1a1e81