Ralf Kistner created CB-10666:
---------------------------------

             Summary: Native callbacks executing in the middle of other JS 
functions
                 Key: CB-10666
                 URL: https://issues.apache.org/jira/browse/CB-10666
             Project: Apache Cordova
          Issue Type: Bug
          Components: iOS
            Reporter: Ralf Kistner


In some cases, the native callback seems to happen in the middle of another JS 
call. Simplified stack trace:

{code}
succeeded@/plugins/io.litehelpers.cordova.sqlcipher/www/SQLitePlugin.js:471:19
handleStatementSuccess@/plugins/io.litehelpers.cordova.sqlcipher/www/SQLitePlugin.js:346:12
/plugins/io.litehelpers.cordova.sqlcipher/www/SQLitePlugin.js:371:38
mycb@/plugins/io.litehelpers.cordova.sqlcipher/www/SQLitePlugin.js:417:20
callbackFromNative@/cordova.js:293:63
/cordova.js:1109:35
nativeEvalAndFetch@/cordova.js:1117:13
nativeCallback@/cordova.js:1106:38
global code@/myindex.html:1:47
removeChild@[native code]
remove@/myscript.js:5506:33
{code}

Often it's not an issue, but in some cases it causes really unexpected 
behaviour, and can cause the application to malfunction in ways that are hard 
to debug. See similar issue previously reported for Android: 
https://issues.apache.org/jira/browse/CB-6181

This happens especially when using a plugin such as SQLite/SQLCipher, which 
triggers a large number of native callbacks.

There does appear to be some code to handle this case - I'm not sure why it's 
not working here:
https://github.com/apache/cordova-ios/blob/9513bc6/CordovaLib/Classes/Public/CDVCommandDelegateImpl.m#L90

The SQLite/SQLCipher plugin does appear to be using multithreading, but I 
haven't confirmed this.

Tested on Cordova-iOS 3.9.2.

A workaround is to wrap all native callbacks in a setTimeout or similar call, 
but this may have some performance impact.



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