WebKit Bugzilla
Attachment 361232 Details for
Bug 194312
: Make sure to clear sources from UserMediaCaptureManagerProxy and UserMediaCaptureManager when no longer needed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194312-20190205154249.patch (text/plain), 12.10 KB, created by
youenn fablet
on 2019-02-05 15:42:54 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-02-05 15:42:54 PST
Size:
12.10 KB
patch
obsolete
>Subversion Revision: 240959 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ab530b19612f8981416d81fa273f189713737ae3..2cf5ba87aab4b00c531d562630386c451c5b6c70 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2019-02-05 Youenn Fablet <youenn@apple.com> >+ >+ Make to clear sources from UserMediaCaptureManagerProxy and UserMediaCaptureManager when no longer needed >+ https://bugs.webkit.org/show_bug.cgi?id=194312 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a way for sources to know when they are ended, i.e. that they will never be started again. >+ No observable change of behavior. >+ >+ * platform/mediastream/RealtimeMediaSource.cpp: >+ (WebCore::RealtimeMediaSource::requestStop): >+ * platform/mediastream/RealtimeMediaSource.h: >+ > 2019-02-05 Youenn Fablet <youenn@apple.com> > > CoreAudioCaptureSource should not configure its audio unit until it starts producing data >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index e59f79177965c54693f7e0db8a0a70d65f9a5bca..d58b468ae8fac31f19e5f36324c6dec72d2444b7 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,27 @@ >+2019-02-05 Youenn Fablet <youenn@apple.com> >+ >+ Make to clear sources from UserMediaCaptureManagerProxy and UserMediaCaptureManager when no longer needed >+ https://bugs.webkit.org/show_bug.cgi?id=194312 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Sources in UserMediaCaptureManager and Proxy are never removed once added to their HashMap. >+ Use the 'ended' mechanism to do the clean-up on WebProcess side. >+ As part of this clean-up, send IPC to UIProcess to do clean-up on proxy side. >+ On WebProcess crash case, clean-up the proxy as well. >+ >+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: >+ (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints): >+ (WebKit::UserMediaCaptureManagerProxy::end): >+ (WebKit::UserMediaCaptureManagerProxy::clear): >+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: >+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: >+ * UIProcess/WebProcessProxy.cpp: >+ (WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch): >+ * WebProcess/cocoa/UserMediaCaptureManager.cpp: >+ (WebKit::UserMediaCaptureManager::sourceEnded): >+ * WebProcess/cocoa/UserMediaCaptureManager.h: >+ > 2019-02-05 Youenn Fablet <youenn@apple.com> > > Simplify applyConstraints callbacks >diff --git a/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp b/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp >index cc54364ce7db42f1fa878864b503aef5fc4b14e6..4938ff96472f677b8ef21edcf119207dfdc8de54 100644 >--- a/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp >+++ b/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp >@@ -137,7 +137,7 @@ void MediaStreamTrackPrivate::endTrack() > m_isEnded = true; > updateReadyState(); > >- m_source->requestStop(this); >+ m_source->requestToEnd(*this); > > forEachObserver([this](auto& observer) { > observer.trackEnded(*this); >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >index 2961b65312e81d2c0d18e6fd59f4a442c1e0112b..ce0f9aaa7922e024b5be716e54a762ac2b6221c0 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >@@ -173,7 +173,7 @@ void RealtimeMediaSource::audioSamplesAvailable(const MediaTime& time, const Pla > > void RealtimeMediaSource::start() > { >- if (m_isProducingData) >+ if (m_isProducingData || m_isEnded) > return; > > m_isProducingData = true; >@@ -196,7 +196,7 @@ void RealtimeMediaSource::stop() > stopProducingData(); > } > >-void RealtimeMediaSource::requestStop(Observer* callingObserver) >+void RealtimeMediaSource::requestToEnd(Observer& callingObserver) > { > if (!m_isProducingData) > return; >@@ -209,10 +209,14 @@ void RealtimeMediaSource::requestStop(Observer* callingObserver) > if (hasObserverPreventingStopping) > return; > >+ auto protectedThis = makeRef(*this); >+ > stop(); >+ m_isEnded = true; >+ hasEnded(); > > forEachObserver([callingObserver](auto& observer) { >- if (&observer != callingObserver) >+ if (&observer != &callingObserver) > observer.sourceStopped(); > }); > } >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >index b4dc547ff72be4766bf600e9661031babc303b95..ab9ed87d44bd5cd5c3bd707ae7c80940a907cb2c 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >@@ -100,7 +100,7 @@ public: > bool isProducingData() const { return m_isProducingData; } > void start(); > void stop(); >- void requestStop(Observer* callingObserver = nullptr); >+ void requestToEnd(Observer& callingObserver); > > bool muted() const { return m_muted; } > void setMuted(bool); >@@ -214,6 +214,8 @@ private: > virtual void stopProducingData() { } > virtual void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) { } > >+ virtual void hasEnded() { } >+ > void forEachObserver(const WTF::Function<void(Observer&)>&) const; > > bool m_muted { false }; >@@ -241,6 +243,7 @@ private: > bool m_interrupted { false }; > bool m_captureDidFailed { false }; > bool m_isRemote { false }; >+ bool m_isEnded { false }; > }; > > struct CaptureSourceOrError { >diff --git a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp >index c51cfea5dcc82a356c4e0a9bb0c0cacf1dba6ce6..154b99701d5bafbd83409a5af64dff36a805530c 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp >+++ b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp >@@ -161,7 +161,8 @@ void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstrai > auto source = sourceOrError.source(); > source->setIsRemote(true); > settings = source->settings(); >- m_proxies.set(id, std::make_unique<SourceProxy>(id, *this, WTFMove(source))); >+ ASSERT(!m_proxies.contains(id)); >+ m_proxies.add(id, std::make_unique<SourceProxy>(id, *this, WTFMove(source))); > } else > invalidConstraints = WTFMove(sourceOrError.errorMessage); > } >@@ -180,6 +181,11 @@ void UserMediaCaptureManagerProxy::stopProducingData(uint64_t id) > iter->value->source().stop(); > } > >+void UserMediaCaptureManagerProxy::end(uint64_t id) >+{ >+ m_proxies.remove(id); >+} >+ > void UserMediaCaptureManagerProxy::capabilities(uint64_t id, WebCore::RealtimeMediaSourceCapabilities& capabilities) > { > auto iter = m_proxies.find(id); >@@ -208,6 +214,11 @@ void UserMediaCaptureManagerProxy::applyConstraints(uint64_t id, const WebCore:: > m_process.send(Messages::UserMediaCaptureManager::ApplyConstraintsFailed(id, result->badConstraint, result->message), 0); > } > >+void UserMediaCaptureManagerProxy::clear() >+{ >+ m_proxies.clear(); >+} >+ > } > > #endif >diff --git a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h >index 3bf921fe680642fcc76e1fbdabf311ea4eda73fd..a52fea25f4d5c334179214e4213705b491ffff57 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h >+++ b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h >@@ -40,10 +40,11 @@ class WebProcessProxy; > > class UserMediaCaptureManagerProxy : private IPC::MessageReceiver { > public: >- UserMediaCaptureManagerProxy(WebProcessProxy&); >+ explicit UserMediaCaptureManagerProxy(WebProcessProxy&); > ~UserMediaCaptureManagerProxy(); > > WebProcessProxy& process() const { return m_process; } >+ void clear(); > > private: > // IPC::MessageReceiver >@@ -53,6 +54,7 @@ private: > void createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const WebCore::CaptureDevice& deviceID, String&&, const WebCore::MediaConstraints&, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings&); > void startProducingData(uint64_t); > void stopProducingData(uint64_t); >+ void end(uint64_t); > void capabilities(uint64_t, WebCore::RealtimeMediaSourceCapabilities&); > void setMuted(uint64_t, bool); > void applyConstraints(uint64_t, const WebCore::MediaConstraints&); >diff --git a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in >index 20db1762fb1682a92447e4788526545f897f9ab6..2a26de7d718e1510e01ea8f4a5e8f7e0c00f0b91 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in >+++ b/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in >@@ -27,6 +27,7 @@ messages -> UserMediaCaptureManagerProxy { > CreateMediaSourceForCaptureDeviceWithConstraints(uint64_t id, WebCore::CaptureDevice device, String hashSalt, struct WebCore::MediaConstraints constraints) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings) LegacySync > StartProducingData(uint64_t id) > StopProducingData(uint64_t id) >+ End(uint64_t id) > Capabilities(uint64_t id) -> (WebCore::RealtimeMediaSourceCapabilities capabilities) LegacySync > SetMuted(uint64_t id, bool muted) > ApplyConstraints(uint64_t id, struct WebCore::MediaConstraints constraints) >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.cpp b/Source/WebKit/UIProcess/WebProcessProxy.cpp >index b2da3bb8765e166f972e596de1e37ef6bed39f72..022fa72b46000405846a1b1e42e1ba89b77d53b8 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/WebProcessProxy.cpp >@@ -571,6 +571,10 @@ void WebProcessProxy::processDidTerminateOrFailedToLaunch() > // to be deleted before we can finish our work. > Ref<WebProcessProxy> protect(*this); > >+#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM) >+ m_userMediaCaptureManagerProxy->clear(); >+#endif >+ > if (auto* webConnection = this->webConnection()) > webConnection->didClose(); > >diff --git a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >index 665253c79bd0ef6c4640cac06f8d829c6e8f84bc..b465ad25239e6b278d3fb407747d89b872998751 100644 >--- a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >+++ b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >@@ -186,6 +186,7 @@ private: > // RealtimeMediaSource > void beginConfiguration() final { } > void commitConfiguration() final { } >+ void hasEnded() final { m_manager.sourceEnded(m_id); } > > void applyConstraints(const WebCore::MediaConstraints& constraints, ApplyConstraintsHandler&& completionHandler) final > { >@@ -343,6 +344,11 @@ void UserMediaCaptureManager::applyConstraints(uint64_t id, const WebCore::Media > m_process.send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints(id, constraints), 0); > } > >+void UserMediaCaptureManager::sourceEnded(uint64_t id) >+{ >+ m_process.send(Messages::UserMediaCaptureManagerProxy::End(id), 0); >+} >+ > void UserMediaCaptureManager::applyConstraintsSucceeded(uint64_t id, const WebCore::RealtimeMediaSourceSettings& settings) > { > ASSERT(m_sources.contains(id)); >diff --git a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >index fcfca9af62dbdc73c477c71969fa217e045da16d..b11ae744c3de1b0bed2712e648a669e1f2305d9f 100644 >--- a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >+++ b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >@@ -85,6 +85,7 @@ private: > // Messages::UserMediaCaptureManager > void captureFailed(uint64_t id); > void sourceStopped(uint64_t id); >+ void sourceEnded(uint64_t id); > void sourceMutedChanged(uint64_t id, bool muted); > void sourceSettingsChanged(uint64_t id, const WebCore::RealtimeMediaSourceSettings&); > void storageChanged(uint64_t id, const SharedMemory::Handle&, const WebCore::CAAudioStreamDescription&, uint64_t numberOfFrames);
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 194312
:
361232
|
361347
|
361412