question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 of freeze. currently pause 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-states

Environment, Platform, Device

Tested with cordova-android and cordova-browser

Version information

Cordova: 9.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
benitogfcommented, Jul 15, 2019

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

1reaction
janpiocommented, Jul 11, 2019

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.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page Lifecycle API - Chrome Developers
The Page Lifecycle API brings app lifecycle features common on mobile operating systems to the web. Browsers are now able to safely freeze ......
Read more >
Page Lifecycle
Frozen: lifecycle state for CPU suspension. This means that the freeze steps algorithm was called on the Document 's browsing context.
Read more >
Deep Dive into Page Lifecycle API | by Viduni Wickramarachchi
As the name suggests, the Page Lifecycle API exposes the web page lifecycle hooks to JavaScript. However, it isn't an entirely new concept....
Read more >
GoogleChromeLabs/page-lifecycle: PageLifecycle.js ... - GitHub
PageLifecycle.js is a tiny JavaScript library (<1K gzipped) that allows developers to easily observe Page Lifecycle API state changes and implement Page ...
Read more >
ASP.NET Page Life Cycle Overview - Microsoft Learn
When an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps. These include...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found