-
Notifications
You must be signed in to change notification settings - Fork 78
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
SBTProxyURLProtocol calls completionHandler in the main thread #206
Comments
Modifying that queue would likely lead to thread-safety issues, so I would recommend against such changes. Instead of blocking the main thread with a semaphore, consider using the run loop (specifically, [NSRunLoop.mainRunLoop runUntilDate:]). While this approach isn't ideal, it could serve as a viable workaround. |
But same difference, UI hangs for 10 seconds until it fails. Main thread is blocked so |
You need to invoke the RunLoop.main.run repeatedly until you detect that your operation is completed. There are a few examples in the tunnel codebase to take a look at. |
@tcamin from what I see, it's really easy to enter a deadlock (see here), which I think it's my case and it's not something very difficult to achieve. I still don't understand why |
Hi, I've noticed that
SBTProxyURLProtocol.startLoading
returns the response for the subbed request in the main thread:Can we use
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
or any other queue that's not the main thread instead (or at least allow customization)? There are scenarios in my suite where I mock HW by using mocks within the main target whose values are customized from a UI-Test. For this, I use dummy http requests. The mocked functions can be async or sync. In order for the sync methods to work I need to block the main thread. However the test hangs indefinitely because the main thread is blocked andSBTProxyURLProtocol
tries to return the data into themain
queue.I don't think the change I suggest breaks anything and I think is more accurate as you'd expect the response to come from a background thread instead of the main thread.
The text was updated successfully, but these errors were encountered: