There was previously no working guard against sniffing the same network event multiple times. This can happen when we swizzle both a class and a superclass that implement one of the delegate methods. Previously, we would log duplicate network events if the class called through to the swizzled method on its superclass. By detecting nested calls, we now avoid the duplicated sniffing.
The issue isn't limited to passing messages up to the superclass, but happens with any forwarding from inside the delegate callback. For example, AFNetworking uses internal delegate objects in AFURLSessionManager (see https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFURLSessionManager.m#L109). If forwardAllNetworkTraffic is used, we'll swizzle the methods on both AFURLSessionManager and AFURLSessionManagerTaskDelegate. We need a guard to ensure we only sniff the network event for the first delegate call, and ignore it on any nested forwarding.
This fixes #141 raised by @mthole
There was previously no working guard against sniffing the same network event multiple times. This can happen when we swizzle both a class and a superclass that implement one of the delegate methods. Previously, we would log duplicate network events if the class called through to the swizzled method on its superclass. By detecting nested calls, we now avoid the duplicated sniffing.
The issue isn't limited to passing messages up to the superclass, but happens with any forwarding from inside the delegate callback. For example, AFNetworking uses internal delegate objects in
AFURLSessionManager
(see https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFURLSessionManager.m#L109). IfforwardAllNetworkTraffic
is used, we'll swizzle the methods on bothAFURLSessionManager
andAFURLSessionManagerTaskDelegate
. We need a guard to ensure we only sniff the network event for the first delegate call, and ignore it on any nested forwarding.