WebKit Bugzilla
Attachment 360934 Details for
Bug 194181
: Make sure to remove the device observer in AVVideoCaptureSource
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194181-20190201174653.patch (text/plain), 4.98 KB, created by
youenn fablet
on 2019-02-01 17:46:54 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-02-01 17:46:54 PST
Size:
4.98 KB
patch
obsolete
>Subversion Revision: 240633 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d5dccab78b26343d9023863149f34dffca6e4769..42fe069a9c9813d2d478d176c26a768d10ccd177 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2019-02-01 Youenn Fablet <youenn@apple.com> >+ >+ Make sure to remove the device observer in AVVideoCaptureSource >+ https://bugs.webkit.org/show_bug.cgi?id=194181 >+ <rdar://problem/47739247> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Make sure to remove the device observer when the observer is destroyed. >+ To simplify things, add the observer in AVVideoCaptureSource constructor and remove it in the destructor. >+ >+ Make also sure the session observer is also removed whenever the session is released by AVVideoCaptureSource. >+ >+ Covered by manual test. >+ >+ * platform/mediastream/mac/AVVideoCaptureSource.h: >+ * platform/mediastream/mac/AVVideoCaptureSource.mm: >+ (WebCore::AVVideoCaptureSource::AVVideoCaptureSource): >+ (WebCore::AVVideoCaptureSource::~AVVideoCaptureSource): >+ (WebCore::AVVideoCaptureSource::initializeSession): >+ (WebCore::AVVideoCaptureSource::clearSession): >+ (WebCore::AVVideoCaptureSource::stopProducingData): >+ (WebCore::AVVideoCaptureSource::setupSession): >+ > 2019-01-30 Babak Shafiei <bshafiei@apple.com> > > Cherry-pick r240633. rdar://problem/47682687 >diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >index 603817263deeb03849c87186418649c034f1fb0d..3f279eb5ee665c52947d95837c8621bbe301d88c 100644 >--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >@@ -73,6 +73,9 @@ private: > AVVideoCaptureSource(AVCaptureDevice*, String&& id, String&& hashSalt); > virtual ~AVVideoCaptureSource(); > >+ void initializeSession(); >+ void clearSession(); >+ > bool setupSession(); > bool setupCaptureSession(); > void shutdownCaptureSession(); >diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >index 16bb821539f05cda2b495d98244b76909fd1a8e6..e7cf44a870abb8ad0d2091ce9944d1f93469d053 100644 >--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >@@ -181,6 +181,8 @@ AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDeviceTypedef* device, Strin > static_assert(static_cast<int>(InterruptionReason::VideoInUse) == AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient, "InterruptionReason::VideoInUse is not AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient as expected"); > static_assert(static_cast<int>(InterruptionReason::AudioInUse) == AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient, "InterruptionReason::AudioInUse is not AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient as expected"); > #endif >+ >+ [m_device.get() addObserver:m_objcObserver.get() forKeyPath:@"suspended" options:NSKeyValueObservingOptionNew context:(void *)nil]; > } > > AVVideoCaptureSource::~AVVideoCaptureSource() >@@ -189,14 +191,27 @@ AVVideoCaptureSource::~AVVideoCaptureSource() > RealtimeMediaSourceCenter::singleton().videoCaptureFactory().unsetActiveSource(*this); > #endif > [m_objcObserver disconnect]; >+ [m_device removeObserver:m_objcObserver.get() forKeyPath:@"suspended"]; > > if (!m_session) > return; > >- [m_session removeObserver:m_objcObserver.get() forKeyPath:@"running"]; >- [m_device removeObserver:m_objcObserver.get() forKeyPath:@"suspended"]; > if ([m_session isRunning]) > [m_session stopRunning]; >+ >+ clearSession(); >+} >+ >+void AVVideoCaptureSource::initializeSession() >+{ >+ m_session = adoptNS([allocAVCaptureSessionInstance() init]); >+ [m_session addObserver:m_objcObserver.get() forKeyPath:@"running" options:NSKeyValueObservingOptionNew context:(void *)nil]; >+} >+ >+void AVVideoCaptureSource::clearSession() >+{ >+ [m_session removeObserver:m_objcObserver.get() forKeyPath:@"running"]; >+ m_session = nullptr; > } > > void AVVideoCaptureSource::startProducingData() >@@ -225,7 +240,7 @@ void AVVideoCaptureSource::stopProducingData() > > m_interruption = InterruptionReason::None; > #if PLATFORM(IOS_FAMILY) >- m_session = nullptr; >+ clearSession(); > #endif > } > >@@ -409,9 +424,7 @@ bool AVVideoCaptureSource::setupSession() > if (m_session) > return true; > >- m_session = adoptNS([allocAVCaptureSessionInstance() init]); >- [m_session addObserver:m_objcObserver.get() forKeyPath:@"running" options:NSKeyValueObservingOptionNew context:(void *)nil]; >- [m_device addObserver:m_objcObserver.get() forKeyPath:@"suspended" options:NSKeyValueObservingOptionNew context:(void *)nil]; >+ initializeSession(); > > [m_session beginConfiguration]; > bool success = setupCaptureSession();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194181
:
360929
|
360934
|
361066