Closed
Bug 1119564
Opened 5 years ago
Closed 5 years ago
TabBarViewController leaks with NotificationCenter reference
Categories
(Firefox for iOS :: General, defect)
Not set
Tracking
()
RESOLVED
FIXED
People
(Reporter: bnicholson, Assigned: bnicholson)
Details
Attachments
(1 file)
Any blocks used as registered NotificationCenter callbacks are strongly held by the NotificationCenter. If we use a strong self inside of that block, that means we'll never be deallocated, and TabBarViewController is never deinited for this reason. We should make sure to use an unowned self to prevent the leak.
Assignee | ||
Comment 1•5 years ago
|
||
Attachment #8546247 -
Flags: review?(wjohnston)
Assignee | ||
Updated•5 years ago
|
Status: NEW → ASSIGNED
Comment 2•5 years ago
|
||
Comment on attachment 8546247 [details] [review] Pull request I'm still surprised viewWillDisappear isn't called here, but the change seems find regardless..
Attachment #8546247 -
Flags: review?(wjohnston) → review+
Assignee | ||
Comment 3•5 years ago
|
||
You were right to be surprised since viewWillDisappear *is* called. The problem is that the notificationToken apparently holds a strong ref to the observer, so even though we've removed the observer from the notification center, we still have a controller -> token -> observer -> block -> controller cycle. Setting the notificationToken to nil in viewWillDisappear is another way to fix this, but I think we should just get in the habit of always passing unowned self to the notification center...or not using the notification center at all with blocks. This nice post explains why: http://sealedabstract.com/code/nsnotificationcenter-with-blocks-considered-harmful/
Assignee | ||
Updated•5 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•