Iñaki Baz Castillo created CB-9102:
--------------------------------------

             Summary: Crash when using a iOS Cordova plugin within a WebSocket 
event
                 Key: CB-9102
                 URL: https://issues.apache.org/jira/browse/CB-9102
             Project: Apache Cordova
          Issue Type: Bug
          Components: iOS
    Affects Versions: 3.8.0
            Reporter: Iñaki Baz Castillo


I've coded a cordova plugin for iOS. It is exported as a JavaScript object with 
multiple functions in `window.cordova.plugins.iosrtc`.

If I use any of those exported functions within the callback of a WebSocket 
event (onopen, onmessage, etc), the plugin/app usually crashes:

-------------------------------
Process 2326 stopped
* thread #1: tid = 0x94ce5, 0x2e267474 
WebCore`WebCore::NavigationScheduler::schedule(std::__1::unique_ptr<WebCore::ScheduledNavigation,
 std::__1::default_delete<WebCore::ScheduledNavigation> >) + 276, queue = 
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x2e267474 
WebCore`WebCore::NavigationScheduler::schedule(std::__1::unique_ptr<WebCore::ScheduledNavigation,
 std::__1::default_delete<WebCore::ScheduledNavigation> >) + 276
WebCore`WebCore::NavigationScheduler::schedule:
->  0x2e267474 <+276>: ldr    r2, [r0]
    0x2e267476 <+278>: ldr    r3, [r2, #0x10]
    0x2e267478 <+280>: mov    r2, r10
    0x2e26747a <+282>: blx    r3
(lldb)
error: No auto repeat.
(lldb) list
   30   {
   31       @autoreleasepool {
   32           int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
   33           return retVal;
   34       }
   35   }
(lldb) bt
* thread #1: tid = 0x94ce5, 0x2e267474 
WebCore`WebCore::NavigationScheduler::schedule(std::__1::unique_ptr<WebCore::ScheduledNavigation,
 std::__1::default_delete<WebCore::ScheduledNavigation> >) + 276, queue = 
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x2e267474 
WebCore`WebCore::NavigationScheduler::schedule(std::__1::unique_ptr<WebCore::ScheduledNavigation,
 std::__1::default_delete<WebCore::ScheduledNavigation> >) + 276
    frame #1: 0x2e26769e 
WebCore`WebCore::NavigationScheduler::scheduleLocationChange(WebCore::SecurityOrigin*,
 WebCore::URL const&, WTF::String const&, WebCore::LockHistory, 
WebCore::LockBackForwardList) + 498
    frame #2: 0x2de00c20 WebCore`WebCore::DOMWindow::setLocation(WTF::String 
const&, WebCore::DOMWindow&, WebCore::DOMWindow&, WebCore::SetLocationLocking) 
+ 172
    frame #3: 0x2e22b0e2 WebCore`WebCore::Location::setHref(WTF::String const&, 
WebCore::DOMWindow&, WebCore::DOMWindow&) + 86
    frame #4: 0x2e03c5d6 
WebCore`WebCore::JSDOMWindow::setLocation(JSC::ExecState*, JSC::JSValue) + 142
    frame #5: 0x2daad47e WebCore`WebCore::JSDOMWindow::put(JSC::JSCell, 
JSC::ExecState, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&) + 446
    frame #6: 0x231a3436 JavaScriptCore`JSC::JSProxy::put(JSC::JSCell, 
JSC::ExecState, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&) + 54
    frame #7: 0x23199fc0 JavaScriptCore`llint_slow_path_put_by_id + 404
    frame #8: 0x233ca3ce JavaScriptCore`llint_entry + 9694
-------------------------------

Sometimes it produces a different error:

--------------------------------
2015-06-01 15:29:17.810 cordovaIosrtcDemo[2298:602476] DiskCookieStorage 
changing policy from 2 to 0, cookie file: 
file:///private/var/mobile/Containers/Data/Application/3588C109-5F97-4E5F-83EA-36165871ACC3/Library/Cookies/Cookies.binarycookies
2015-06-01 15:29:18.083 cordovaIosrtcDemo[2298:602476] Apache Cordova native 
platform version 3.8.0 is starting.
2015-06-01 15:29:18.083 cordovaIosrtcDemo[2298:602476] Multi-tasking -> Device: 
YES, App: YES
2015-06-01 15:29:18.088 cordovaIosrtcDemo[2298:602476] Unlimited access to 
network resources
2015-06-01 15:29:18.277 cordovaIosrtcDemo[2298:602476] iosrtcPlugin#init()
2015-06-01 15:29:18.325 cordovaIosrtcDemo[2298:602476] PluginGetUserMedia#init()
2015-06-01 15:29:18.326 cordovaIosrtcDemo[2298:602476] [CDVTimer][iosrtcplugin] 
55.085003ms
2015-06-01 15:29:18.326 cordovaIosrtcDemo[2298:602476] 
[CDVTimer][TotalPluginStartup] 55.342019ms
2015-06-01 15:29:18.967 cordovaIosrtcDemo[2298:602476] Resetting plugins due to 
page load.
2015-06-01 15:29:19.432 cordovaIosrtcDemo[2298:602476] Finished load of: 
file:///private/var/mobile/Containers/Bundle/Application/90A5F156-4893-490C-B608-A7D3715F379D/cordovaIosrtcDemo.app/www/index.html
Process 2298 stopped
* thread #8: tid = 0x931b5, 0x21e410e8 CoreFoundation`CFRelease + 1268, name = 
'WebThread', stop reason = EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, 
subcode=0xdefe)
    frame #0: 0x21e410e8 CoreFoundation`CFRelease + 1268
CoreFoundation`CFRelease:
->  0x21e410e8 <+1268>: trap
    0x21e410ea <+1270>: trap

CoreFoundation`_CFAllocatorDeallocateGC:
    0x21e410ec <+0>:    push   {r4, r7, lr}
    0x21e410ee <+2>:    mov    r4, r1
--------------------------------


IMPORTANT: If I run a setTimeout within the WebSocket event and run the plugin 
function inside it, the app DOES NOT crash.

It may be related to https://issues.apache.org/jira/browse/CB-2301

NOTE: This issue is NOT about sleep/resume at all as it happens immediately 
when I open the app and a WebSocket connects.




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