[ 
https://issues.apache.org/jira/browse/CB-4560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13747050#comment-13747050
 ] 

Peter commented on CB-4560:
---------------------------

Please consider the following scenario where the keepRunning flag toggles from 
true to false causing pauseTimers (in step 5) to not behave as intended. 

0. (starting out with keepRunning=true)
1. activity.onResume -> resumeTimers() -> ++refcount [refCount is now 1]
2. activity.onPause(keepRunning=true) -> pauseTimers is not called because 
keepRunning is true 
3. activity.onResume -> resumeTimers() -> ++refcount [refCount is now 2]
4. change to keepRunning=false
5. activity.onPause(keepRunning=false) -> pauseTimers() -> --refcount [refCount 
is now 1] -> but this won't pause timers on GINGERBREAD because refCount not 0

AFAIK the toggle of the keepRunning flag from true to false (in step 4) can 
happen because of code in CordovaActivity.startActivityForResult

{code}
// If multitasking turned on, then disable it for activities that return results
if (command != null) {
    this.keepRunning = false;
}
{code}
                
> Android call to pauseTimers might not pause timers
> --------------------------------------------------
>
>                 Key: CB-4560
>                 URL: https://issues.apache.org/jira/browse/CB-4560
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.9.0
>         Environment: GingerBread devices
>            Reporter: Peter
>            Assignee: Joe Bowser
>
> Older Android versions (eg GINGERBREAD) had some quirk where the API 
> pauseTimers/resumeTimers was controlled by an internal reference counter.
> Refer to 
> http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/webkit/JWebCoreJavaBridge.java/?v=diff&id2=2.3.3_r1
>  
> It means that unless the pauseTimers/ResumeTimers were carefully balanced 
> then calling these API methods might not actually be doing what the caller 
> expects. 
> The CordovaWebView.java code calls to the Android pauseTimers/resumeTimers 
> are not balanced (the call to pauseTimers is conditional but the call to 
> resumeTimers is unconditional). Because of this, there would be some scenario 
> where resumeTimers gets called more times than pauseTimers, and in such a 
> case the pauseTimers is not actually going to do anything on a GINGERBREAD 
> device.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to