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

Shazron Abdullah commented on CB-8468:
--------------------------------------

My initial thought was to add to build-debug.xcconfig in 
GCC_PREPROCESSOR_DEFINITIONS:
DEBUG=1

This is set in the project when you do "cordova build"/"cordova build --debug" 
(default is debug)

And in the CDVPluginResult, pass in an extra property "debug" set to true 
(based on the macro set). This will be passed back to JavaScript in the args 
here:
https://github.com/apache/cordova-ios/blob/b07c174250842b023c20762839f66b05d87d21cf/CordovaLib/cordova.js#L265

And then we pass args.debug to cordova.callbackFromNative on the next line, and 
it handles it based on that boolean

> Application freezes if breakpoint hits JavaScript callback invoked from native
> ------------------------------------------------------------------------------
>
>                 Key: CB-8468
>                 URL: https://issues.apache.org/jira/browse/CB-8468
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS, iOS
>            Reporter: Marcus Pridham
>            Priority: Minor
>             Fix For: 4.0.0
>
>
> It you attach Safari to your application and hit a breakpoint in a Cordova 
> callback the application freezes and you can't step through or continue.  
> This only happens in breakpoints in the native to JavaScript callbacks.  
> JavaScript breakpoints in other areas work fine.   
> A simple way to reproduce is to use the globalization plugin.  Attach safari 
> and put a breakpoint in the success callback.
> {code}
> navigator.globalization.getPreferredLanguage(function() {
>         console.log("test"); // Will freeze if breakpoint set here
>     }, function() {});
> {code}
> The problem seems to have to  do with the webview 
> stringByEvaluatingJavaScriptFromString.  It is a synchronous call that can 
> return the result of the JavaScript back to the native.  The native code will 
> crash if a breakpoint is hit while trying to execute the JavaScript.  The 
> workaround is to have your callback code in a setTimeout so it is not in the 
> same context as the native stringByEvaluatingJavaScriptFromString call.
>  
> A workaround:
>  
> Open cordova.js and around line 281 replace:
>  {code}
> callbackFromNative: function(callbackId, isSuccess, status, args, 
> keepCallback) {
>  {code}
> With:
>  {code}
>     callbackFromNative: function(callbackId, isSuccess, status, args, 
> keepCallback) {
>        setTimeout(function() {
>             cordova.callbackFromNative2(callbackId, isSuccess, status, args, 
> keepCallback);
>         }, 0);
>     },
>        
>     callbackFromNative2: function(callbackId, isSuccess, status, args, 
> keepCallback) {
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to