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

unsubscribe on channel enumeration causing crash #842

Closed
mattheworiordan opened this issue Apr 15, 2019 · 5 comments
Closed

unsubscribe on channel enumeration causing crash #842

mattheworiordan opened this issue Apr 15, 2019 · 5 comments
Assignees
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@mattheworiordan
Copy link
Member

mattheworiordan commented Apr 15, 2019

Which version of the Ably SDK are you using?

github "ably/ably-ios" == 1.1.2

On which platform does the issue happen?

iOS 12

What did you do?

        channels.forEach {
            ablyClient.channels.get($0).unsubscribe()
        }

What did you expect to happen?

Not a crash!

What happened instead?

Screen Shot 2019-04-15 at 10 06 25 AM

@mattheworiordan mattheworiordan added the bug Something isn't working. It's clear that this does need to be fixed. label Apr 15, 2019
@ricardopereira
Copy link
Contributor

realtime.channels.get("groups").subscribe("foo", onAttach: { error in
    self.realtime.channels.get("groups").unsubscribe() //<-- crash
}, callback: { message in
    print(message)
})

^ this will crash with a EXC_BAD_INSTRUCTION (SIGTRAP).

Stack trace:

#0	0x000000010efa10c7 in __DISPATCH_WAIT_FOR_QUEUE__ ()
#1	0x00007000052f1e90 in 0x7000052f1e90 ()
#2	0x000000010efa0ab9 in _dispatch_sync_f_slow ()
#3	0x000000010bf8c18c in -[ARTChannels getChannel:options:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTChannels.m:80
#4	0x000000010bf8bd0b in -[ARTChannels get:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTChannels.m:61
#5	0x000000010c00f99e in -[ARTRealtimeChannels get:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTRealtimeChannels.m:52
#6	0x000000010b852412 in closure #1 in ViewController.sendNotificationButtonTapped(_:) at /Users/mac/dev/ably-experiments/source/ViewController.swift:57
#7	0x000000010b8524ad in partial apply for closure #1 in ViewController.sendNotificationButtonTapped(_:) ()
#8	0x000000010b8524f2 in thunk for @escaping @callee_guaranteed (@guaranteed ARTErrorInfo?) -> () ()
#9	0x000000010bf9dbb3 in __24-[ARTEventEmitter once:]_block_invoke at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTEventEmitter.m:227
#10	0x000000010c8e8706 in -[__NSObserver _doit:] ()
#11	0x000000010de0e5ec in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#12	0x000000010de0da6f in _CFXRegistrationPost ()
#13	0x000000010de0d7b3 in ___CFXNotificationPost_block_invoke ()
#14	0x000000010def15e2 in -[_CFXNotificationRegistrar find:object:observer:enumerator:] ()
#15	0x000000010de0d101 in _CFXNotificationPost ()
#16	0x000000010c8e8eaf in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#17	0x000000010bf9e8d3 in -[ARTEventEmitter emit:with:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTEventEmitter.m:275
#18	0x000000010c0020d5 in -[ARTRealtimeChannel setAttached:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTRealtimeChannel.m:658
#19	0x000000010c000f0e in -[ARTRealtimeChannel onChannelMessage:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTRealtimeChannel.m:590
#20	0x000000010bfe7ee0 in -[ARTRealtime onChannelMessage:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTRealtime.m:938
#21	0x000000010bff07b3 in -[ARTRealtime realtimeTransport:didReceiveMessage:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTRealtime.m:1328
#22	0x000000010c044e1f in -[ARTWebSocketTransport receive:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTWebSocketTransport.m:106
#23	0x000000010c044eee in -[ARTWebSocketTransport receiveWithData:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTWebSocketTransport.m:111
#24	0x000000010c047d74 in -[ARTWebSocketTransport webSocketMessageData:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTWebSocketTransport.m:366
#25	0x000000010c0478d0 in -[ARTWebSocketTransport webSocket:didReceiveMessage:] at /Users/mac/dev/ably-experiments/Pods/Ably/Source/ARTWebSocketTransport.m:348
#26	0x000000010d382b02 in __43-[SRWebSocket _handleFrameWithData:opCode:]_block_invoke.252 at /Users/mac/dev/ably-experiments/Pods/SocketRocketAblyFork/SocketRocket/SRWebSocket.m:829

The onAttachCallback is probably calling the block in the internal queue and it's wrong.

@mattheworiordan
Copy link
Member Author

is probably calling the block in the internal queue and it's wrong.

Thanks for investifgating. @ricardopereira are you saying thtat that's fault though in the SDK or the caller. I would argue that whilst odd, it's still valid.

@ricardopereira
Copy link
Contributor

@mattheworiordan It's a SDK issue. All user callbacks should use the user queue, not the internal one.

@mattheworiordan
Copy link
Member Author

It's a SDK issue

Ok.

@ricardopereira
Copy link
Contributor

@mattheworiordan Fix has been implemented. Just waiting for the CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

2 participants