Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Crash after subscribing to channel #103

Closed
Moussawi7 opened this issue Mar 4, 2015 · 5 comments
Closed

App Crash after subscribing to channel #103

Moussawi7 opened this issue Mar 4, 2015 · 5 comments

Comments

@Moussawi7
Copy link

Hi @pl,
I have a chat mobile application(using cordova) that use pusher to serve messages,
the application is working excellent on android devices, and IOS 7-, but it crash on IOS8.
After debugging i discovered that when i subscribe to a channel and use (Sqlite plugin)[www.github.com/brodysoft/Cordova-SQLitePlugin] in the same time, the application crash.
Therefore, i think that they use the same ports...
Did you hear about this issue before!!. and please let me know about the ports used by pusher-js.
Thank you.

@pl
Copy link
Contributor

pl commented Mar 9, 2015

Hi,

I don't think SQLite uses the same ports as Pusher - normally pusher-js connects to 80 for unencrypted connections and 443 for encrypted ones.

I'm not a specialist in iOS development, it might be an issue with the SQLite plugin or Cordova - they contain native code and are first suspects for me. JS code should not really crash applications. It's hard to tell where the problem is.

Maybe a dirty hack is to try calling SQLite and Pusher functions in separate ticks (using setTimeout with 0 timeout). You can try that to see if it helps, but it's a really ugly solution (horrible flow control, possible race conditions) and I'd rather not have such code in a production app ;)

@Moussawi7
Copy link
Author

Hi @pl ,
First thank you for you help.
As you said " _JS code should not really crash applications_ ", and for this reason i spent around 3 hours to discover the reason of the issue.
anyway, your trick work for me, and the crash never happened again so thanks for your help(you are always helpful).

@machty
Copy link

machty commented Feb 2, 2016

Related: https://issues.apache.org/jira/browse/CB-9102

I just fixed this bug in my app: it happens if, within the same event loop that you handle a pusher callback (or any callback that ultimately originates from a native WebSocket event), you make a call through cordova back into native code. It is "fixed" by setting a JS timeout before handling the event.

@pl integrating Pusher with Cordova (or a Cordova-like environment) is very common, and this bug is tricky and misleading enough that it might be beneficial to just build the setTimeout into the pusher JS lib to prevent these issues from happening in the first place. I don't think this would affect user apps in any way, whether it be timing or performance. And FWIW it would probably have to be a timer, and not anything tricky like using MutationObservers to do a next tick.

@ituhin
Copy link

ituhin commented Oct 28, 2016

@machty how did you integrate pusher for push notifications in your cordova app ?
is there a javascript client lib to register device push tokens with pusher channels ?
or did you write one yourself ?

@hph
Copy link
Contributor

hph commented Nov 3, 2016

@machty For now I think this issue will be enough for anyone that runs into a similar problem, but I think you raised a good point and we will look into implementing that in the future.

@hph hph closed this as completed Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants