2

Our OSX app is uploading multiple files to the server using

func uploadTask(withStreamedRequest request: URLRequest) -> URLSessionUploadTask

While uploading, the upload gets stuck. Some files manage to upload successfully, sometimes more files other times less.

Looking at the debug navigator I can see that my stream thread shows two calls (one after the other; frame 11 and frame 5) to stream:handleEvent delegate, that points me to the code line where i call write:maxLength on NSOutputStrem, following __psynch_mutexwait in frame 0. At this point app is stuck and no network calls can finish executing.

enter image description here
Did anyone come across this issue? Any help is appreciated, thanks.

Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
Max
  • 799
  • 1
  • 5
  • 17

1 Answers1

1

It looks like your handler is being signaled twice to write to the same stream. Add a check that the streamStatus is NSStreamStatusWriting and return early.

Konrad Piascik
  • 679
  • 5
  • 9
  • Thanks for the response, i've tried that but unfortunately it didn't work. Eventually, what we did was to dispatch async to our own queue from the delegate call and that seems to fix the deadlock issue. At the moment i can still see that some upload requests get 'stuck' (via Charles) and data is just not being written to the stream object. When that happens we get timeout event and drop the request. i still fear that there is an issue with the framework. – Max Oct 16 '18 at 13:32