Code Monkey home page Code Monkey logo

Comments (16)

mcmurrym avatar mcmurrym commented on July 20, 2024

my particular freeze may not be related to Apples reason.

Here is the stacks on the two competing threads:

Thread 1, Queue : com.apple.main-thread
#0 0x38c08adc in semaphore_wait_trap ()
#1 0x38b4742c in _dispatch_semaphore_wait_slow ()
#2 0x38c920da in xpc_connection_send_message_with_reply_sync ()
#3 0x305071c6 in _reach_server_target_add ()
#4 0x30507072 in __SCNetworkReachabilityServer_targetAdd ()
#5 0x304e748e in __SCNetworkReachabilityGetFlags ()
#6 0x304e7d16 in SCNetworkReachabilityGetFlags ()
#7 0x005a1a62 in -[PNReachability synchronousStatusFlags] at Pods/PubNub/iOS/iPadDemoApp/pubnub/libs/PubNub/Network/PNReachability.m:666
#8 0x005a147a in -[PNReachability handleOriginLookupCompletionWithData:response:error:] at Pods/PubNub/iOS/iPadDemoApp/pubnub/libs/PubNub/Network/PNReachability.m:556
#9 0x005a0e44 in __41-[PNReachability handleOriginLookupTimer]_block_invoke_2 at Pods/PubNub/iOS/iPadDemoApp/pubnub/libs/PubNub/Network/PNReachability.m:482
#10 0x38b3fd1a in _dispatch_call_block_and_release ()
#11 0x38b3fd06 in _dispatch_client_callout ()
#12 0x38b4678c in _dispatch_main_queue_callback_4CF$VARIANT$mp ()
#13 0x2dd85818 in CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE ()
#14 0x2dd840ec in __CFRunLoopRun ()
#15 0x2dceec26 in CFRunLoopRunSpecific ()
#16 0x2dceea0a in CFRunLoopRunInMode ()
#17 0x329ef282 in GSEventRunModal ()
#18 0x30592048 in UIApplicationMain ()
#19 0x00098048 in main at main.m:16


Thread 7 com.apple.NSURLConnectionLoader, Queue : (null)
#0 0x38c08adc in semaphore_wait_trap ()
#1 0x38b4742c in _dispatch_semaphore_wait_slow ()
#2 0x38c920da in xpc_connection_send_message_with_reply_sync ()
#3 0x30507d2a in _reach_server_target_unschedule ()
#4 0x30507c22 in __SCNetworkReachabilityServer_targetUnschedule ()
#5 0x304e8660 in _SCNetworkReachabilityUnscheduleFromRunLoop ()
#6 0x304e8996 in SCNetworkReachabilitySetDispatchQueue ()
#7 0x2d9b579c in SocketStream::removeNetworkReachability_NoLock() ()
#8 0x2d9b55da in SocketStream::close(void const
) ()
#9 0x2d9b558c in CoreStreamBase::_streamInterface_Close() ()
#10 0x2d9d3e60 in HTTPWriteFilter::_streamImpl_Close() ()
#11 0x2d9b558c in CoreStreamBase::streamInterface_Close() ()
#12 0x2d9d3dee in NetConnection::shutdownConnectionStreams() ()
#13 0x2d9d461c in NetConnection::closeStreamsIfPossibleOrSignalThatThatNeedsToBeDonePrettyPlease() ()
#14 0x2d9d496a in HTTPConnectionCacheEntry::removeUnauthConnection(NetConnection
) ()
#15 0x2dcee658 in CFArrayApplyFunction ()
#16 0x2da193e2 in HTTPConnectionCacheEntry::purgeIdleConnections(double, double) ()
#17 0x2d9d472c in HTTPConnectionCache::performIdleSweep() ()
#18 0x2da178de in HTTPConnectionCache::timeoutIdleCellConnections() ()
#19 0x2da572be in ___ZNK17CoreSchedulingSet13_performAsyncEPKcU13block_pointerFvvE_block_invoke ()
#20 0x2dcee658 in CFArrayApplyFunction ()
#21 0x2d9bdb34 in RunloopBlockContext::perform() ()
#22 0x2d9bda04 in MultiplexerSource::perform() ()
#23 0x2d9bd898 in MultiplexerSource::_perform(void*) ()
#24 0x2dd86182 in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION ()
#25 0x2dd85652 in CFRunLoopDoSources0 ()
#26 0x2dd83e46 in __CFRunLoopRun ()
#27 0x2dceec26 in CFRunLoopRunSpecific ()
#28 0x2dceea0a in CFRunLoopRunInMode ()
#29 0x2e7292f6 in +NSURLConnection(Loader) _resourceLoadLoop:
#30 0x2e79ec86 in __NSThread__main
()
#31 0x38c83c1c in _pthread_body ()
#32 0x38c83b8e in _pthread_start ()

Note that the 2 stacks deal with Apples code and Your code. I would not consider this a bug on my part.

from objective-c.

geremyCohen avatar geremyCohen commented on July 20, 2024

@mcmurrym Taking a look...

from objective-c.

parfeon avatar parfeon commented on July 20, 2024

@mcmurrym which one is crashed? Number of crashed tread?

from objective-c.

mcmurrym avatar mcmurrym commented on July 20, 2024

@parfeon No crash. It is dead locked.

from objective-c.

parfeon avatar parfeon commented on July 20, 2024

@mcmurrym not sure on whether it is PubNub library fault. As for synchronous DNS resolving with SCNetworkReachabilityCreateWithName. synchronousStatusFlags method check whether there is some connection on interface layer, it doesn't go out of device scope and ends it's check on interface layer.

from objective-c.

parfeon avatar parfeon commented on July 20, 2024

@mcmurrym can you share some small piece of code which can be used to try reproduce this issue?

from objective-c.

mcmurrym avatar mcmurrym commented on July 20, 2024

@parfeon I'm not sure what I would share... neither stack I provided has any code from my application. It is pubnub code and Apple code. We make network requests through NSURLConnections objects and we make them asynchronously. At the time we are seeing the freeze we are making/made anywhere from 10-30 requests. They are managed from an NSOperationQueue. You can see in the stacks the each thread is attempting to mutate a list of some sort containing server names. One is trying to add and the other is trying to unschedule.

from objective-c.

mcmurrym avatar mcmurrym commented on July 20, 2024

we did not see this problem with the previous version.

from objective-c.

mcmurrym avatar mcmurrym commented on July 20, 2024

@parfeon I'm not sure I understand your comment on synchronous DNS resolving...

from objective-c.

geremyCohen avatar geremyCohen commented on July 20, 2024

@mcmurrym Please contact us at [email protected]. I think we'll be able to resolve this quicker through opening a formal ticket with us.

geremy

from objective-c.

parfeon avatar parfeon commented on July 20, 2024

@mcmurrym did you try to use PubNub across different threads? At this moment it doesn't support multithreading.
I'm asking for small piece of code of your application to see how you are using PubNub library and try to reproduce issue on our side.
As for synchronous DNS resolving - there is no place where we do so. SCNetworkReachabilityGetFlags on reachability instance which is configured to check device interfaces (w/o attempt to resolve DNS) - so this function inside synchronousStatusFlags won't lock main thread.

from objective-c.

mcmurrym avatar mcmurrym commented on July 20, 2024

@parfeon

- (void)unsubscribe
{
    [PubNub unsubscribeFromChannels:[PubNub subscribedChannels]];
    [PubNub disconnect];
}

- (void)connectToPubNub:(NSDictionary *)results
{
    NSString *subscribeKey = [results objectForKey:kEventSubscribeKeyKey];

    [PubNub setClientIdentifier:[NSString stringWithFormat:@"%@:%@", PNUniqueIdentifier(), [User currentUser].numberIdentifier]];

    [PubNub setConfiguration:[PNConfiguration configurationForOrigin:kEventPubNubOrigin
                                                          publishKey:self.pubnubPublishKey
                                                        subscribeKey:subscribeKey
                                                           secretKey:self.pubnubSecretKey]];
    [PubNub connectWithSuccessBlock:^(NSString *sucess) {
        NSString *companyChannelName = [results objectForKey:kEventCompanyChannelKey];

        PNChannel *companyChannel = [PNChannel channelWithName:companyChannelName shouldObservePresence:YES];

        [PubNub subscribeOnChannel:companyChannel];

        NSString *personalChannelName = [results objectForKey:kEventPersonalChannelKey];

        PNChannel *personalChannel = [PNChannel channelWithName:personalChannelName shouldObservePresence:NO];

        [PubNub subscribeOnChannel:personalChannel];

    } errorBlock:^(PNError *failure) {

    }];   
}

- (void)pubnubClient:(PubNub *)client didReceiveMessage:(PNMessage *)message
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [self processMessage:message];
    });
}

The delegate is set elsewhere, but it is set.

The call back that is freezing appears to be running on a timer being called back again and again.

from objective-c.

parfeon avatar parfeon commented on July 20, 2024

@mcmurrym connectToPubNub called from main thread? Also are you sure that none of PubNub methods has been called from non-main thread elsewhere?

from objective-c.

mcmurrym avatar mcmurrym commented on July 20, 2024

@parfeon Yes all the pubnub action happens on the main thread. I submitted a bug on multi-threading issues a while ago :)

from objective-c.

parfeon avatar parfeon commented on July 20, 2024

@mcmurrym well, code itself doesn't show any issues and it looks like PubNub library affected by your application's environment.
I think we should continue our discussion in [email protected]
P.S. just last question on whether there is some callbacks to the PubNub library inside processMessage method?

from objective-c.

geremyCohen avatar geremyCohen commented on July 20, 2024

@mcmurrym just checking in -- we're eager to assist. Please contact us at [email protected], and let us know the answer to Sergey's last query re:

"P.S. just last question on whether there is some callbacks to the PubNub library inside processMessage method?"

thanks,
geremy

from objective-c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.