-
I face to the thread checker error:
The store has been created on the main thread - Queue: com.apple.main-thread So, the thread checking should not be based on DispatchSpecificKey, as Apple uses more queues on the main thread. I also face to another issue: When app went to background, I send an action called .applicationDidEnterBackground from the AppDelegate method. This action is not coming on the main thread, however still should be safe, as main thread cannot send anything else. (Yes, not sure whether reducer cannot still run something on the main thread, but is there any better solution?) Any help. please? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
@hibernat Sorry about that! We may not have the thread checking logic quite right yet. Can you type
Can you throw this |
Beta Was this translation helpful? Give feedback.
-
My understanding is, that UIKit always updates UI from the main thread, however this does not mean that this is updated from the same dispatch queue. |
Beta Was this translation helpful? Give feedback.
-
@stephencelis Thanks for your time spent on this!!! This method: func applicationDidEnterBackground(_ application: UIApplication) { produces this: applicationDidEnterBackground Warning: A store created on the main thread was interacted with on a non-main thread: Thread: <NSThread: 0x6000007bc940>{number = 31, name = (null)} An effect returned from the action "ChatAction.applicationDidEnterBackground" completed on a non-main thread. Make sure to use ".receive(on:)" on any effects that execute on background threads to receive their output on the main thread, or create this store via "Store.unchecked" to disable the main thread checker. The "Store" class is not thread-safe, and so all interactions with an instance of "Store" (including all of its scopes and derived view stores) must be done on the main thread. The issue with diffable data source seems to be fixed. However, I have found another issue. Code: NotificationCenter.default.publisher(for: .userSchoolIdDidChangeNotification) Results in this: userSchoolIdDidChangeNotification Warning: A store created on the main thread was interacted with on a non-main thread: Thread: <NSThread: 0x600002fb3580>{number = 22, name = (null)} An effect returned from "ChatAction.userEnvironmentDidChange" emitted the action "ChatAction.getMemberships(....)" on a non-main thread. Make sure to use ".receive(on:)" on any effects that execute on background threads to receive their output on the main thread, or create this store via "Store.unchecked" to disable the main thread checker. The "Store" class is not thread-safe, and so all interactions with an instance of "Store" (including all of its scopes and derived view stores) must be done on the main thread. My apologies, I have to sleep (I am a couple of hours ahead of you) |
Beta Was this translation helpful? Give feedback.
-
@stephencelis I have just double checked whether the store is created on the main thread (Thread.isMainThread). Yes, it is... |
Beta Was this translation helpful? Give feedback.
-
@hibernat are you using |
Beta Was this translation helpful? Give feedback.
-
@stephencelis The issue with effect Thanks, @iampatbrown . One |
Beta Was this translation helpful? Give feedback.
-
Tangentially related, recently some SwiftUI animations are executed off the main thread. |
Beta Was this translation helpful? Give feedback.
@stephencelis The issue with effect
ChatAction.userEnvironmentDidChange
is resolved. Error on my side.Thanks, @iampatbrown . One
receive(on:)
is not enough whenflatMap
is used...