You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And when this runs, delegate.callCount remains 0 and there is no delegate called message in the console.
Standalone Example
I've reproduced this case in the URLSessionInstrumentationTests and in the standalone Network Sample. My full code change is here.
Potential Solution
It appears that the URLSession instrumentation uses task delegates to manage its instrumentation. It looks at outgoing tasks (ie. here) and, if they don't have a task delegate, it attaches one. However, as far as I can tell, that means the iOS runtime never calls the session delegate, because it thinks the task already has a delegate.
We could update this FakeDelegate to accept the existing session delegate and proxy that. I prototyped this here, and all of the existing tests, as well as the new ones I added in the standalone example above, pass.
The text was updated successfully, but these errors were encountered:
The Problem
For example, let's say we have this session delegate:
and then we use this as a delegate for our session and make a synchronous request, everything is fine. For example:
After this runs,
delegate.callCount
will be1
anddelegate called
will be printed in the console. So far so good.If we switch to making our request async and use this delegate as a delegate for the task, things are still fine. For example:
Then, again, this works the same as above.
However, if we make the request async and use this delegate as the delegate for the entire session, then things fall apart. That code looks like this:
And when this runs,
delegate.callCount
remains0
and there is nodelegate called
message in the console.Standalone Example
I've reproduced this case in the
URLSessionInstrumentationTests
and in the standaloneNetwork Sample
. My full code change is here.Potential Solution
It appears that the URLSession instrumentation uses task delegates to manage its instrumentation. It looks at outgoing tasks (ie. here) and, if they don't have a task delegate, it attaches one. However, as far as I can tell, that means the iOS runtime never calls the session delegate, because it thinks the task already has a delegate.
We could update this
FakeDelegate
to accept the existing session delegate and proxy that. I prototyped this here, and all of the existing tests, as well as the new ones I added in the standalone example above, pass.The text was updated successfully, but these errors were encountered: