Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove general usage of Window unload event #9908

Open
niloc132 opened this issue Jan 25, 2024 · 0 comments
Open

Remove general usage of Window unload event #9908

niloc132 opened this issue Jan 25, 2024 · 0 comments

Comments

@niloc132
Copy link
Contributor

GWT version: GWT 2.11 and below
Browser (with version): Chrome 120 (soft rollout, see chrome link below)
Operating System: any


Description

Browsers are removing the unload even on the browser, as there are replacements available, and the unload event can interfere with newer browser features. See the MDN docs on the unload event for more specifics.

Chrome specifically has a deprecation policy that is warning that this will be removed in the future. For GWT's own usage of unload, this shouldn't matter:

  • Other window events are removed when this event goes off, to avoid memory leaks (only applies to ancient browsers)
  • RootPanel itself adds a close handler to ensure that all widgets are disconnected, to avoid memory leaks (as above, no longer applies)
  • The long-deprecated WindowCloseListener handling also uses this feature.
Steps to reproduce

Use some Window/RootPanel API directly to monitor unload events, or indirectly with window resize/scroll/beforeunload events (such as with PlaceController, DialogBox, RootLayoutPanel). In chrome, you may see a warning/errors that unload events are deprecated for removal.

To fix this, we can probably remove this class of "memory-leak prevention" (which no longer applies in any browser created in the last ten years) - this means RootPanel need not use it, and Window need not initialize close handlers for window resize/scroll events. Likewise, split unload/beforeunload handling to separate initializers.

Window.addCloseHandler should also be deprecated.

This should probably be backported, given Chrome's timeline for this deprecation, unless we get 2.12 to a finished state (and it is barely started) in the next few weeks.

Links to further discussions

https://groups.google.com/g/google-web-toolkit/c/ZVc9yztBurs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant