Cannot access property with a non-sendable type from non-isolated deinit

Let me focus on this and ask the same question I asked above, slightly differently: what bad would happen if UIView / UIViewController deinits were called on a background thread? And a followup question: what makes these types special compared to a type of my own?

Let's try find answer here in the famous Deallocation Problem description.

As I can see here the only special thing about UIView/UIViewController (subclass) is that "it is common" they do something in their dealloc that's main thread only... hence we do this "last release special treatment" in the OS to combat this common situation... and thus reduce the number of crashes in users' apps significantly... right? hmm... I can write this class, would that be "too unusual" to ignore?

class Foo { // not a UIView or a UIViewController
    deinit {
        let v = UIView() // or any other main-thread only thing
        print(v)
    }
}

IMHO, whatever we do in this area should handle 99.999% cases... not "the most typical" 95% cases. Last release treatment is a hack that highlights a problem, and frankly, looks like a quick band-aid approach rather than a proper solution. I'd rather see we create a proper solution that allows removing that hack, than build some partial solution around that hack.

1 Like