"Unload event listeners are deprecated" browser error

100 views
Skip to first unread message

Óscar Frías Barranco

unread,
Jan 25, 2024, 11:18:39 AMJan 25
to GWT Users
Hello.

Browsers running our GWT application (version 2.11) have recently (this week) started reporting errors like this one:

[{"age":41550,"body":{"columnNumber":192,"id":"UnloadHandler","lineNumber":3210,"message":"Unload event listeners are deprecated and will be removed.","sourceFile":"ourmodule-0.js"},"type":"deprecation","url":"oururl","user_agent":"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Mobile Safari/537.36"}]

Any idea about why is this happening?  Is GWT using a deprecated browser feature?

Thanks!
Oscar

Thomas Broyer

unread,
Jan 25, 2024, 12:38:53 PMJan 25
to GWT Users
Yes: https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event
Apparently, this happens when you use Window.addXxxHandler (and for instance the default PlaceController's delegate calls Window.addClosingHandler, which registers an unload handler but is only interested in the beforeunload event)

Colin Alworth

unread,
Jan 25, 2024, 1:39:55 PMJan 25
to GWT Users
It looks like the purpose of registering the unload handler for any Window event is to avoid IE6-10 era memory leaks. From the notes on the MDN page, removing those other handlers will break the page when the bfcache is in use, but our use of the unload handler will opt GWT pages out.

The simplest fix appears to be to stop initializing the unload event tracking for resize/scroll events, and "let" those leak (which they won't, because IE in all forms is really-actually-totally-dead this time, right?). Next unload/beforeunload should be decoupled, so that each can be initialized separately. Then applications can remove their own usage of unload as they wish, but we should probably deprecate this event handler method (not the event and handler itself) as well.

Reply all
Reply to author
Forward
0 new messages