We currently use the same queue for the nw_browser and
nw_connection, which may have been a bad idea
No, that should be fine.
We do not explicitly release the queue anywhere because we thought ARC
handled releases.
Correct.
The reason I brought that up is that it’s not uncommon for C++ code to not use ARC.
It is not clear to me what type of ownership nw_browser_set_queue
and nw_connection_set_queue keeps for the queue (shared or weak
ptr?).
I took a quick look at that yesterday and confirmed that the browser object definitely maintains a strong reference to the queue that you set via nw_browser_set_queue. And while I didn’t specifically check this, I fully expect that the connection object will do the same.
Could ARC be releasing the queue when we set our reference to NULL
and before an async process in browser_cancel?
No. The browser object maintains its own reference up to the point where you cancel it, at which point it definitely schedules the state changed handler block on the queue before it releases its reference. And after that Dispatch should retain the queue until its drained.
It’s a bit of a mystery really. Have you tried to reproduce this problem by enabling zombies?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"