cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Kane (JIRA)" <>
Subject [jira] [Commented] (CB-2301) EXC_BAD_ACCESS on resume/wake on iOS device
Date Tue, 19 Nov 2013 20:01:22 GMT


Paul Kane commented on CB-2301:

I was having lots of similar problems with my Cordova project. In XCode I was regularly seeing
crashes. But following Ross's suggestion I seem to have gotten past them.

This is just an FYI post, not a thoroughly detailed recounting of what I did to (seemingly)
fix my problems, but I submit it in case it's helpful to anyone else. I'm using Cordova 3.1.0
and my iPhone 5s is iOS 7.0.4.

To start, I created a sample project, added the client library, and after deviceready
I would connect to my server. If I ran my app, let it connect, then suspended my app (hit
the iPhone home button, say), I could see the socket connection close on my server after about
30 seconds. If I then locked my iPhone (manually), woke it back up, and then re-opened my
app, I could see in XCode that the "disconnect" event didn't fire until after the
phone was awakened. This seemed strange, but probably the best you could do "out of the box"
since has no knowledge of Cordova's "pause" and "resume" events. Once awakened, would then reconnect automatically to the server. However, about 3.5 minutes after
I woke it up, the app would crash. The ~3.5 minutes was strangely reliable (I could set a
timer and wait for it).

A weird (but possibly important side note) : I believe that this only happened to me if I
had a plugin loaded (any plugin). I have 6 plugins in my normal project and any 1 of them
seemed to trigger the crash. Without a plugin, the app wouldn't seem to crash (could be wrong
about this though).

Eventually what I did -- because obviously not using plugins wasn't an option -- was to capture
the Cordova "pause" and "resume" events and MANUALLY do a socket.disconnect() and socket.socket.connect()
(respectively). This was Ross's suggestion. It's just a dash more work, but seems to have
made all the difference. Now the "disconnect" event happen in the background before
the app goes into completely suspension, and not after waking up. This feels "cleaner" somehow,
without JS and the real network state getting out of sync. (I sure am glad that apps are allowed
to run for a few seconds after they've been suspended, exactly for this kind of situation.)

I also manually manage reconnections now too, rather than letting handle them. This
might not be critical, but it made it easier for me to keep in my head the workflow of things.
Now when I call socket.disconnect() it stays disconnected, and doesn't try to immediately,
automatically re-establish a connection in the brief "background" state before the app is

P.S. : I think that changing "BackupWebStorage " to "none" might also have helped (it seems
like it was crashing faster and at a different point if that was set to "cloud"). However
this change on its own wasn't enough to solve the problems completely.

> EXC_BAD_ACCESS on resume/wake on iOS device
> -------------------------------------------
>                 Key: CB-2301
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 2.2.0
>         Environment: iPhone 5 running iOS 6.0.2 and Phonegap 2.2.0. (Xcode 4.5.2 on Mountain
>            Reporter: Ross Holdway
>            Assignee: Shazron Abdullah
>            Priority: Critical
>              Labels: cordova, ios, phonegap
>             Fix For: 2.5.0
>         Attachments:, Screenshot.png
> I have implemented a websocket connection (using within my app which it uses
to communicate with the server. On locking and waking the device, it disconnects and reconnects
correctly, but on leaving the device locked for 1 minute or longer when unlocking, the application
will crash sometimes instantly, or sometimes after reconnecting with the server.
> If I do the same, but run my app within mobile Safari, it does not crash, leading me
to believe this is an issue with Phonegap/Cordova. 
> On app crash, within Xcode I get within WebThread - WebCore::ThreadTImers::sharedTimerFiredInternal()
an EXC_BAD_ACCESS (code=1) error
> Screenshot of crash state in Xcode -
> Hopefully someone will have an idea as to what could be causing this, or recommend some
tests for me to run etc because I'm really clueless on how to proceed with fixing this!
> Many Thanks,
> Ross

This message was sent by Atlassian JIRA

View raw message