Closed benitogf closed 5 years ago
The cordova-android lifecycle crashes
What's the connection to cordova-browser
here?
think that cordova-browser could use the page lifecycle events, as stated above a browser changing tabs shouldn't require a pause
event imho
Ok, but what is crashing? Or did you mean "clash"?
Even then I don't understand how something from cordova-android
is relevant for cordova-browser
? Or does browser implement the current stuff right now?
in the browser resume
and pause
are called on visibility change (https://github.com/apache/cordova-browser/blob/master/cordova-js-src/platform.js#L35), think that it could further filter the trigger to actual lifecycle events like freeze
and resume
, the reason why I included the link to cordova-android docs is because I couldn't find a lifecycle specification for cordova-browser
Oh sorry I did meant "clash", updated the ticket
I am not even sure if there is any special lifecycle handling for cordova-browser
- it probably comes from the browser itself I guess. But we will have to look into the code further here.
So your issue is more like a feature request to better integrate the page lifecycle API you linked to, and not about a problem or bug that currently exists?
would consider it a bug rather than a new feature since there's already an implementation in cordova-browser
but not sure
regardless of an integration with the page lifecycle API, a visibility change should trigger pause
?
my experience was that implementing lifecycle events works fine on android but made the application "pause" on every tab change when deployed to the browser
my experience was that implementing lifecycle events works fine on android but made the application "pause" on every tab change when deployed to the browser
Ah, now we are getting concrete. That is not normal browser behavior?
That is not normal browser behavior?
Is not in my opinion, but open to different ideas
The easiest way to find out (and also later to test and verify any implementation in cordova-browser
) would be a super simple Cordova app / index.html
that outputs the events that are occuring either in the console or in a div on a page.
Could you create one of those and put them on GitHub? (Bonus points if you follow these instructions for a minimal reproduction repository: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md - because that will minimize the time we contributors have to spend to set this up.)
Hello @janpio I got around this by checking the user agent before adding the event listener to filter the desktop browser which works even for the webview build (https://developer.chrome.com/multidevice/user-agent):
if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
document.addEventListener('pause', () => {})
document.addEventListener('resume', () => {})
}
I realize that the page lifecycle events are not implemented on other browsers and that some applications might depend on current behavior of cordova-browser
events so closing this one for now, thanks
Bug Report
Problem
The cordova-android lifecycle clashes with the page lifecycle spec.
What is expected to happen?
There should be some integration between cordova lifecycle and the page lifecycle
What does actually happen?
The cordova even 'resume' name clashes with 'resume' of page lifecycle
Information
The browser
pause
event could be a proxy offreeze
. currentlypause
will trigger even on a browser tab change, which makes sense on the mobile webview, but not so much on a browser.Command or Code
The easiest way to test integration with page lifecycle that I found so far is with
chrome://discards/
as stated here https://developers.google.com/web/updates/2018/07/page-lifecycle-api#testing-your-app-in-the-frozen-and-discarded-statesEnvironment, Platform, Device
Tested with cordova-android and cordova-browser
Version information
Cordova: 9.0
Checklist