grpc-swift icon indicating copy to clipboard operation
grpc-swift copied to clipboard

Channel connectivityState crash after shutdown

Open a-voronov opened this issue 5 years ago • 0 comments

New Issue Checklist

Issue Description

I'm using Swift gRPC on iOS and trying to keep connection when device switches between wifi<>cellular or different cellular technologies as suggested here #337.

So I shutdown active service client channel. And next time I talk to client, I want to check whether it's shutdown or not, so I can decide if I need to create new client or use the current one. The only way to do it AFAIK is to call its channel's connectivityState method. But I get EXC_BAD_ACCESS when calling it, after channel was shutdown. I suppose it happens after underlying channel pointer is freed in shutdown method and I try to access if afterwards in connectivityState method.

I don't know much about implementation details whether we should keep underlying channel pointer alive so we can keep using it to get its state, or whether we should rely on some secondary knowledge if it was shutdown like hasBeenShutdown private flag, so I couldn't create PR to fix it.

Environment

Key Value
OS Version 10.14.4
Swift Version 4.2
Xcode Version 10.2.1
gRPC-Swift Version 0.9.0

a-voronov avatar Jun 18 '19 14:06 a-voronov