Page MenuHomePhabricator

[iOS 10 Beta 2] Fix Dealloc crash when view is destroyed before FBKVOController cleans up its observation
Closed, ResolvedPublic

Description

https://rink.hockeyapp.net/manage/apps/152731/app_versions/51/crash_reasons/124126709?scope=os_versions&type=statistics

This crash is due to a change in Apple's KVO logic… they are more aggressive during the dally process.

Practically this means we need to remove the observation before dealloc finishes. This can be done by:

  1. updating FBKVOController (maybe?)
  2. Manually cleaning up any observations of views in dealloc (error prone)
  3. Playing with the memory semantics of (non-retaining KVO controller) to see if this can be solved (idk??)
  4. Removing FBKVOController and returning to manually cleaning up our observations

From Apple:

  • Wikipedia has a view controller that holds onto a FBKVOController as an associated reference
  • AND that vc uses FBKVOController to observe a view
  • AND when that view controller is deallocated it triggers deallocation of the observed view

Because the view controller’s dealloc hasn’t finished, the associated FBKVOController won’t be deallocated yet. The deallocation of the view will pop the autorelease pool, call NSKVODeallocate, and thrown an exception.

You will need to clean up your observation in dealloc before calling super / killing the view hierarchy that you are observing.

Event Timeline

JMinor triaged this task as Medium priority.Jul 25 2016, 7:30 PM
JMinor moved this task from Needs Triage to Bug Backlog on the Wikipedia-iOS-App-Backlog board.