-
Notifications
You must be signed in to change notification settings - Fork 130
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
tryFlushOutbox is not thread-safe #230
Comments
Also it is easy to reproduce with following steps:
|
I have to admit, I'm not really happy with PTNativePusher, I feel like its a bit of a rush-job, but I haven't had time to work on the library myself recently. I intend to revisit this when I get the chance. |
Also having this issue, if I attempt to subscribe to more than one interest in succession (I've coded a non-ideal workaround using timeouts for now) 👎 |
Also having this issue. Is the best work-around a |
Having this issue on the |
For when I had to perform subscriptions in batch, I ended up having to use a promise and then once resolved, set a timeout of at least 100ms before firing the next one. According to their support we're supposed to be using PusherSwift instead (even though their documentation directs us to libPusher). However it's a swift library and messes up my cocoapods to have a mix of objective-c and swift, so I haven't had the time yet to devote to it. |
@robinschaaf any chance you can share your code for this? both js and objective c? I have setup a bridged module but am experiencing the same issue. Im very new to the objective c side so any help would be appreciated. |
@b8ne sure! I'm also a newbie to objective-c, so I'm not sure that this is the right way, but it seems to work.
Then this is all of the pertinent objective-c code, that allows you to refer to the pusher via the NativeModules
AppDelegate.m:
NotificationSettings.h:
NotificationSettings.m:
Hope that helps! |
hey @robinschaaf thanks heaps for sharing. Just after I posted to you I found this. Obviously its not merged, so not sure if it will be legit, but ive tested it and it works. Now my code is like this NotificationManager.m
AppDelegate.m
AppDelegate.h
I havent looked too far into objective c multithreading, but im guessing i could probably do without the async stuff now, but its working so im just going to leave it. |
As reported by a user in support (thanks!):
Steps to reproduce
Call some combination of
registerWithDeviceToken
,subscribe
, andunsubscribe
concurrentlyExpected behavior
Eventually, all the subscribe/unsubscribe calls are processed in the order in which they were called
Actual behavior
This line ...
libPusher/Library/PTNativePusher.m
Line 123 in 436268e
... crashes with the error:
Reason
(Hypothesized, not reproduced)
tryFlushOutbox
is not threadsafe. Between lookup object at index 0, and then removing the object at index 0, things may have changed. This may happen iftryFlushOutbox
is called multiple times: they will interfere with each other.The text was updated successfully, but these errors were encountered: