HTML: Window becomes null


on chrome mobile the window function of Application.hx returns null if the phone is locked for a while. So the html game works fine, you lock the phone, unlock of some seconds, everything is fine. But if you keep it locked for a while, window will become null. No messages in the log. A timer is still running, but the game freezes.

I have no idea where to start looking, any ideas here?

Thx in advance!

Could it be that this is triggering?

This will cause the window to be removed from the application, because the window is considered closed. It’s strange that a page could dispatch an unload event, then be active again (rather than doing a full reload), but I suppose it is possible. Thank you for your help :slight_smile:

1 Like

Yes, it is triggered. I logged the window events and excactly 5 minutes after the phone is locked, the beforeunload event is triggered:

09:07:15.378 HTML5Application.hx:322: handleWindowEvent: blur
09:12:15.564 HTML5Application.hx:322: handleWindowEvent: beforeunload
09:13:20.625 HTML5Application.hx:322: handleWindowEvent: focus

The focus is triggered when i unload the phone again.

I’m not a 100% sure, but i think it worked some time ago without problems. Maybe a new Chrome version changed this.

So what to do now? :slight_smile:

I’m making this change in Lime for now:

I wonder if we should use “load” instead (and if that is not actually dispatched on sleep?) though I think “beforeunload” was used because it was cancelable, and maybe allowed network activity.

Since the application comes back, with the window dead already, I feel like we need to just let it run and not close it for now, unless we’re sure the page is truly dead?

1 Like