You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Michal Mocny (JIRA)" <ji...@apache.org> on 2012/10/30 16:30:12 UTC

[jira] [Commented] (CB-1746) IOS events onAppWillResignActive and onAppDidEnterBackground do not execute JS until after app is launched again.

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

Michal Mocny commented on CB-1746:
----------------------------------

Fixed in https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-ios.git;a=commit;h=e545a4ba974a543fe02b9e3c0ac11c95c9645404

Fix is two fold:
First, onAppDidEnterBackground had to call cordova.fireDocumentEvent('pause', null, true);  <-- needs the two extra parameters to signal fireDocumentEvent to NOT use setTimeout(..., 0).
Second, added CDVCommandDelegate (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop  to be used by both events in order to process plugin calls from js return value *without* scheduling on run loop.

Together, this makes the resign and pause events run as synchronously as possible, so as not to give up the process context -- since it would not resume until app is foregrounded again.


onAppWillResignActive did not need the two extra parameters, because it is not an officially registered cordova event (is dispatched using document.dispatchEvent(evt), and that one is not wrapped with a setTimeout -- go figure).  I could make resign(and its sibling 'active') an official event inside common.js but was unable to do so from the ios platform specific js.  Going to file a separate issue for that.. but this works as is.
                
> IOS events onAppWillResignActive and onAppDidEnterBackground do not execute JS until after app is launched again.
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: CB-1746
>                 URL: https://issues.apache.org/jira/browse/CB-1746
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 2.2.0
>            Reporter: Michal Mocny
>            Assignee: Andrew Grieve
>            Priority: Blocker
>             Fix For: 2.2.0
>
>
> We run js handlers with [self.commandDelegate evalJs:...] but I've also tried replacing this with [self.webView stringByEvaluatingJavaScriptFromString:...].
> Not sure how to fix this yet, but Andrew claims this is a regression.

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