belozierov / SwiftCoroutine

Swift coroutines for iOS, macOS and Linux.
https://belozierov.github.io/SwiftCoroutine
MIT License
836 stars 51 forks source link

Is it possible to support iOS 10 or lower? #14

Closed seven332 closed 4 years ago

seven332 commented 4 years ago

I tried running the tests on iOS 10 simulator. Some problems came up.

  1. CoFutureAwaitTests.testConcurrency was stuck It seems the test scale is too large. It passed after reducing the scale.

  2. random EXC_BAD_ACCESS after CoroutineContextTests.testInitWithPageGuard Comment out the mprotect(stack, .pageSize, PROT_READ) in CoroutineContext.init, or add mprotect(stack, .pageSize, PROT_READ | PROT_WRITE) in CoroutineContext.deinit, the test passes. Maybe the granularity of protection changes is as large as an entire region, as the document said. https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/mprotect.2.html

So I'm curious why the requirement is iOS 11.0+.

belozierov commented 4 years ago

@seven332 Thank you for your work done.

  1. It looks like DispatchQueue.asyncAfter on previous versions of iOS works really bad, and with a large number of calls it takes a lot of time to process. But this is not a problem for the framework itself, but only for tests where it is used.

  2. As for ‘mprotect’, there is definitely a bug in the framework, and I will fix it through ‘CoroutineContext.deinit’.

In previous versions of the framework, I used api which was available from iOS 11, now I do not use it. So there is no reason why it should not work on iOS 10.

I'll fix it and set the version from 10. The only thing I don't have is a device with such an old version to test it properly.

Thanks again!