ios-multithreading

Is it possible to execute something on main thread after didEnterBackground is called?

女生的网名这么多〃 提交于 2020-08-09 19:34:08
问题 First of all I'd like to say sorry in case you consider my question dummy, I'm new to iOS and multithreading and just want to understand how things are going on. As far as I know didEnterBackground is the last function that iOS calls before app suspension and the app has about 5 secs to return from it otherwise iOS will kill the app. I'm currently thinking about such a situation - I have some task that is happening on the background thread(e.g. network download) and its completion block

Ocassional crash on the app start

天涯浪子 提交于 2020-02-05 03:26:46
问题 I'm getting very strange crash at the start of the app. My app spawns a lot of threads (over 500, most of them are related to PLPreheatItem, I can not paste full crash log here, cause stackoverflow has limit to 30K symbols). The problem is that I can not reproduce it on my device. Also it happens on clean install for my customer almost every run. I am using NSURLSession with background session and NSOperationQueue with 4 concurrent operations. These are the most weak parts as I think. Could

Xcode Incorrectly Reporting Swift Access Race Condition

限于喜欢 提交于 2019-12-18 17:38:06
问题 I believe XCode is incorrectly reporting Swift Access Race in my SynchronizedDictionary - or is it? My SynchronizedDictionary looks like this: public struct SynchronizedDictionary<K: Hashable, V> { private var dictionary = [K: V]() private let queue = DispatchQueue( label: "SynchronizedDictionary", qos: DispatchQoS.userInitiated, attributes: [DispatchQueue.Attributes.concurrent] ) public subscript(key: K) -> V? { get { return queue.sync { return self.dictionary[key] } } mutating set { queue

Why do we need to call the Main Thread for UI updates?

☆樱花仙子☆ 提交于 2019-12-08 08:24:42
问题 I know that we have to call the main thread when we update the UI. But I can't explain my teammates why we have to do it and why Swift doesn't do it automatically. They used to call self.present() like this: self.present(alert, animated: true) But I know you should call it this way: DispatchQueue.main.async { self.present(alert, animated: true) } I actually would like to make sure the method is always called on the main thread but I don't know how... The other question is: Why do I have to

Why do we need to call the Main Thread for UI updates?

∥☆過路亽.° 提交于 2019-12-07 00:56:29
I know that we have to call the main thread when we update the UI. But I can't explain my teammates why we have to do it and why Swift doesn't do it automatically. They used to call self.present() like this: self.present(alert, animated: true) But I know you should call it this way: DispatchQueue.main.async { self.present(alert, animated: true) } I actually would like to make sure the method is always called on the main thread but I don't know how... The other question is: Why do I have to make sure this method is called on the main thread and not Swift? There always is an UI update when

Multithreaded rendering only crashes on iOS 13

可紊 提交于 2019-12-01 20:02:23
问题 In my game engine, I have an option to enable the multithreaded rendering. In iOS 12 (and below) my app did not crash. I have not changed anything in my code, but it crashes on iOS 13. 2019-10-02 11:36:07.931 SimpleGame[293:11150] ---> (Inner Exception #0) Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: threading violation: expected the main thread Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 0 CoreFoundation

Multithreaded rendering only crashes on iOS 13

戏子无情 提交于 2019-12-01 19:24:35
In my game engine, I have an option to enable the multithreaded rendering. In iOS 12 (and below) my app did not crash. I have not changed anything in my code, but it crashes on iOS 13. 2019-10-02 11:36:07.931 SimpleGame[293:11150] ---> (Inner Exception #0) Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: threading violation: expected the main thread Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 0 CoreFoundation 0x00000001aace1c44 97285ACB-7B21-393A-ABF6-03F1DBB5D2A2 + 1256516 Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 1