You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Joe Bowser <bo...@gmail.com> on 2012/11/06 19:41:22 UTC

[Android] Question about onPause vs pauseTimers()

Hey

Apparently the pause and resume bug still exists, and I think it's caused
by the pause and resume timers not being executed properly.  I'm looking at
the Private API to see what this actually does so I can try and write a
JUnit test for this, but I'm not clear what the difference between
EventHub.ON_PAUSE and EventHub.PAUSE_TIMERS is exactly?  Does anyone who is
more familiar with the WebKit side of things know? Do we need to pause the
timers if we're actually calling onPause on the WebViewClassic view?

Any ideas?

RE: [Android] Question about onPause vs pauseTimers()

Posted by Jonathan Bond-Caron <jb...@openmv.com>.
On Tue Nov 6 01:41 PM, Joe Bowser wrote:
> Hey
> 
> Apparently the pause and resume bug still exists, and I think it's 
> caused by the pause and resume timers not being executed properly.
> I'm looking at the Private API to see what this actually does so I can 
> try and write a JUnit test for this, but I'm not clear what the 
> difference between EventHub.ON_PAUSE and EventHub.PAUSE_TIMERS is 
> exactly?  Does anyone who is more familiar with the WebKit side of 
> things know? Do we need to pause the timers if we're actually calling 
> onPause on the WebViewClassic view?
> 
> Any ideas?

Hi Joe, here are some of my notes. The only thing I understand about
resumeTimers() is there's a potential 'refcount' bug:
http://code.google.com/p/google-mobile-dev/issues/detail?id=9

-- Pause WebViewCore

Create an illusion of pausing the webView by slowing down of DOM timers
(less cpu usage / lower battery usage)
Also disables geolocation & sends 'pause' event (kPause_ANPLifecycleAction)
to webkit plugins (e.g. flash).

JAVA:
onPause()  EventHub.ON_PAUSE
onResume() EventHub.ON_RESUME

CPP:
https://github.com/android/platform_external_webkit/blob/master/Source/WebKi
t/android/jni/WebViewCore.cpp#L4795

The interesting part is that setMinDOMTimerInterval() changes TIMER to 1s
(paused) from 0.04s (resume)  
https://bugs.webkit.org/show_bug.cgi?id=45362

viewImpl->sendPluginEvent() sends the 'pause' event to webkit plugins and
then back to JAVA (via plugin bindings).
http://www.slideshare.net/seiyonl/android-webkit-browser-plugin


-- Pause WebView timers

Tries to close network connections and temporarily disables javascript
timers?

resumeTimers() EventHub.RESUME_TIMERS
pauseTimers()  EventHub.PAUSE_TIMERS

Pausing changes the *thread* priority to THREAD_PRIORITY_BACKGROUND.

Don't understand what 'JWebCoreJavaBridge' does with timers and it looks
buggy.

http://code.google.com/p/google-mobile-dev/issues/detail?id=9
http://blog.csdn.net/elfylin/article/details/7072406