Mac AVFoundation: check -CrAVCaptureDevice::observationInfo before removing observers.
During Chrome shutdown, DeviceMonitorMac deallocs CrAVFoundationDeviceObserver, which is registered as an observer of suspended and connected events on the CrAVCaptureDevice. Every so seldom (see bugs), the removal of these observers causes a crash. Observers removal seems to be a long standing problem with Cocoa and Objective-C++. This CL speculates with a solution for this trouble via testing if the protocol method -observationInfo [1] is not |nil| before removing the observers. This is based on the observation that: a) There might be an AVFoundation-internal race between observer removal and AVCaptureDevice destruction. b) A previous, unrelated Chrome crash might have left the AVFoundation into some unstable meta state. (This is based on xians@ hitting this bug during browser_tests). Tested locally and seems to work fine. BUG=288562, 371271 [1] https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueObserving_Protocol/Reference/Reference.html#jumpTo_10 Review URL: https://codereview.chromium.org/274073002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269603 0039d316-1c4b-4281-b951-d872f2087c98
Showing
Please register or sign in to comment