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
I have seen this deadlock too on iOS. I believe the problem with runBlocking() is that it is blocking the main thread without letting iOS process any blocks (coroutines) enqueued on the native GDC main queue. On iOS Dispatchers.Main uses this queue to asynchronously run coroutines.
I have experimented with making my own version of runBlocking() for my tests which uses NSRunLoop.mainRunLoop.runUntilDate(...) to give GDC a chance to process the queued blocks. It works, coroutines are run, but my understanding of coroutine internals is not deep enough to make it reliable (e.g. waiting for all descendant jobs to complete).
I see that there's a concept of an EventLoop in the coroutines internals which I don't fully understand. Perhaps a custom EventLoop impl for the iOS main thread could make runBlocking() pump the main thread run loop as needed and prevent the deadlocking?
Consider the very simple unit test:
This test runs and finishes fine on JVM or native with the main (non-mt) version, but with the mt version it hangs indefinitely.
The text was updated successfully, but these errors were encountered: