fix: Never use unload event on modern browsers
Window unload event is extremely unreliable, it doesn't fire in multiple scenarios, especially in mobiles. Replacing "unload" by "pagehide" event.
PR for issue https://github.com/SAP/openui5/issues/3085
https://developers.google.com/web/updates/2018/07/page-lifecycle-api?utm_source=lighthouse&utm_medium=devtools#legacy-lifecycle-apis-to-avoid https://web.dev/bfcache/ https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event
Pull request is going to be reviewed as part of BLI CPOUI5FRAMEWORK-203.
Dear @mauriciolauffer,
thank you for your contribution by providing the PR. We already addressed the browser-side deprecation of the 'unload' event within sap/ui/core with the changes below.
- Prepare for upcoming 'unload' event deprecation and deprecate APIs 'onWindowBeforeUnload', 'onWindowUnload' and 'onWindowError' in 'sap/ui/core/Component'
- Support.js: Replace "unload" event
We discussed the possible solutions internally and came to the conclusion that we are not able to keep the exact behavior working, since the deprecation of the 'unload' event also activates the BF cache in many cases. Therefore we decided to deprecate the 'wrapper' APIs on the Component and to remove the usage of the 'unload' event in the most other cases, since they were not needed there at all.
Anyway many thanks for your contribution!
Kind regards, Johannes