Skip to content

Accessing the Store on the com.apple.SwiftUI.AsyncRenderer thread #2767

Answered by mbrandonw
gerfarfel asked this question in Q&A
Discussion options

You must be logged in to vote

This issue was referenced in the comments for discussion #2694 on this forum, but without a solution. (Sorry if I've missed other references to the problem.)

Ah yes, sadly that conversation went over to email and I forgot to update the thread.

We should document this somewhere, but the problem is with any kind of lazy view, such as the LazyVGrid you have in your demo. Such views apparently construct view hierarchy on non-main threads, which cause stores to be created on non-main threads (due the laziness of _StoreCollection).

Someday in the future (once the dust settles on Swift concurrency), stores will be thread safe and this will be fine. But until then you need to eager turn your st…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@mbrandonw
Comment options

@gerfarfel
Comment options

@topkim993
Comment options

@gerfarfel
Comment options

@topkim993
Comment options

Answer selected by gerfarfel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants