Andy Victors
07/23/2021, 5:10 PMitnoles
07/23/2021, 5:33 PMAbhishek Dewan
07/24/2021, 12:51 AMTijl
07/24/2021, 8:10 AMpointer({ })
if that makes sense (since you say you understand memory models in general that should help).
Then this pointer (created on the thread you are on), is passed to the async method, which in the end causes it to be accessed from the main thread. Since you did not freeze it (the closure, i.e. the pointer and what it points to), an exception occurs.Andy Victors
07/24/2021, 9:03 AMTijl
07/24/2021, 9:09 AMAndy Victors
07/24/2021, 9:59 AMAndy Victors
07/25/2021, 10:25 AMTijl
07/26/2021, 8:53 AMcallback
that jumps back into K/N code but obviously it is guess work with the information presented (not helped by how vague K/N stacktraces are). So likely the problem is callback
or whatever it calls is not frozen.
indeed if you’d port this code to K/N instead of Swift freezing the closure would also freeze callback
(or whatever it references), but since this object should come from K/N somewhere, you can call freeze
on it there yourself before it is ever passed to Swift