YoYoGames/GameMaker-HTML5

Stopping the game for any Unhandled Rejection

trumdu opened this issue · 4 comments

trumdu commented

GameMaker stop when any unhandled exception occurs. Found the reason in the file _GameMaker.js

function yyUnhandledRejectionHandler( error )
{
	var string =  "Unhandled Rejection - " + error.message;
	print( string );
	//alert( string );
	game_end(-2);
	debugger;
	return false;
}

window.addEventListener( "unhandledrejection", yyUnhandledRejectionHandler );

The game stop even if an unhandled exception appears in the Extension when the asynchronous function is running. Exception handling for asynchronous function added.

return payments.purchase(r)
            .then((t) => {
                return this.trigger("PaymentsPurchase", t), void window.focus();
            })
            .catch((e) => {
                console.warn(e), this.trigger("PurchaseError"), window.focus();
            });

I think the game needs to output an error message to the browser console, and not stop game.

function yyUnhandledRejectionHandler( error )
{
	console.error("Unhandled Rejection - " + error.message);
	return false;
}

I just wanted to add more context to increase the urgency of this issue.

For months GM developers who have their games published on Poki have been experiencing a pretty exotic issue where their games would crash after loading if adblock is on. Apparently, when adblock is on, Google Ads keep throwing up errors and depending on their timing... One of those errors is caught by GM and game_end() is called.

An early workaround was to delay the initialization of the game by 5-6 seconds, which felt wrong and negatively impacted player experience. Now, that the cause is known, I guess, we can just remove the handlers.

rwkay commented

Thanks for the context for this... we will look at changing the handling of this...

you can fix this locally using this repo and build with that in the meantime.

trumdu commented

Hi. I suggest checking the source of the exception. If it is with a different URL or outside the folder with the game, then we only output an error to the console.

YoYoGames/GameMaker-HTML5/pull/251

kPatch commented

This issue needs to be re-opened. The issue still persists. The game breaks when an unhandledrejection error is thrown in the hosting HTML/JS application. @rwkay @trumdu