Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: content/browser/device_monitor_mac.mm

Issue 274073002: Mac AVFoundation: check -CrAVCaptureDevice::observationInfo before removing observers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/device_monitor_mac.mm
diff --git a/content/browser/device_monitor_mac.mm b/content/browser/device_monitor_mac.mm
index 5491aa640eec7d595651fc86290aca82eaee63f8..ae720cbdd9686017b2b934438eb6af6e00e1b8f5 100644
--- a/content/browser/device_monitor_mac.mm
+++ b/content/browser/device_monitor_mac.mm
@@ -378,10 +378,15 @@ void AVFoundationMonitorImpl::StartObserverOnDeviceThread() {
std::set<CrAVCaptureDevice*>::iterator found =
std::find(monitoredDevices_.begin(), monitoredDevices_.end(), device);
DCHECK(found != monitoredDevices_.end());
- [device removeObserver:self
- forKeyPath:@"suspended"];
- [device removeObserver:self
- forKeyPath:@"connected"];
+ // Every so seldom, |device| might be gone when getting here, in that case
+ // removing the observer causes a crash. Try to avoid it by checking sanity of
+ // the |device| via its -observationInfo. http://crbug.com/371271.
+ if ([device observationInfo]) {
+ [device removeObserver:self
+ forKeyPath:@"suspended"];
+ [device removeObserver:self
+ forKeyPath:@"connected"];
+ }
monitoredDevices_.erase(found);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698