Modified: trunk/Source/WebCore/ChangeLog (252496 => 252497)
--- trunk/Source/WebCore/ChangeLog 2019-11-15 19:56:09 UTC (rev 252496)
+++ trunk/Source/WebCore/ChangeLog 2019-11-15 20:08:08 UTC (rev 252497)
@@ -1,3 +1,25 @@
+2019-11-15 Chris Dumez <[email protected]>
+
+ Regression: http/tests/navigation/page-cache-getUserMedia-pending-promise.html is crashing in Debug
+ https://bugs.webkit.org/show_bug.cgi?id=204232
+
+ Reviewed by Eric Carlson.
+
+ No new tests, covered by http/tests/navigation/page-cache-getUserMedia-pending-promise.html.
+
+ * Modules/mediastream/MediaStreamTrack.cpp:
+ (WebCore::MediaStreamTrack::create):
+ (WebCore::MediaStreamTrack::MediaStreamTrack):
+ Call suspendIfNeeded() in the factory and not in the constructor. It is never safe to call
+ suspendIfNeeded() from inside the constructor because it may call the suspend() method, which
+ may ref |this|.
+
+ * Modules/mediastream/UserMediaRequest.cpp:
+ (WebCore::UserMediaRequest::allow):
+ Queue a task on the HTML event loop when the user media request is approved. This way, if the
+ page is suspended when this happens, we delay constructing the media stream (among other things)
+ until the page actually resumes.
+
2019-11-15 Zalan Bujtas <[email protected]>
[LFC][Invalidation] Reuse FrameViewLayoutContext::m_layoutState for incremental layout
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (252496 => 252497)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2019-11-15 19:56:09 UTC (rev 252496)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2019-11-15 20:08:08 UTC (rev 252497)
@@ -62,7 +62,9 @@
Ref<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext& context, Ref<MediaStreamTrackPrivate>&& privateTrack)
{
- return adoptRef(*new MediaStreamTrack(context, WTFMove(privateTrack)));
+ auto track = adoptRef(*new MediaStreamTrack(context, WTFMove(privateTrack)));
+ track->suspendIfNeeded();
+ return track;
}
MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, Ref<MediaStreamTrackPrivate>&& privateTrack)
@@ -73,7 +75,6 @@
, m_mediaSession(PlatformMediaSession::create(*this))
{
ALWAYS_LOG(LOGIDENTIFIER);
- suspendIfNeeded();
m_private->addObserver(*this);
Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp (252496 => 252497)
--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp 2019-11-15 19:56:09 UTC (rev 252496)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp 2019-11-15 20:08:08 UTC (rev 252497)
@@ -231,47 +231,49 @@
{
RELEASE_LOG(MediaStream, "UserMediaRequest::allow %s %s", audioDevice ? audioDevice.persistentId().utf8().data() : "", videoDevice ? videoDevice.persistentId().utf8().data() : "");
- auto callback = [this, protector = makePendingActivity(*this), completionHandler = WTFMove(completionHandler)](RefPtr<MediaStreamPrivate>&& privateStream) mutable {
- auto scopeExit = makeScopeExit([completionHandler = WTFMove(completionHandler)]() mutable {
- completionHandler();
- });
- if (isContextStopped())
- return;
+ queueTaskKeepingObjectAlive(*this, TaskSource::UserInteraction, [this, audioDevice = WTFMove(audioDevice), videoDevice = WTFMove(videoDevice), deviceIdentifierHashSalt = WTFMove(deviceIdentifierHashSalt), completionHandler = WTFMove(completionHandler)]() mutable {
+ auto callback = [this, protector = makePendingActivity(*this), completionHandler = WTFMove(completionHandler)](RefPtr<MediaStreamPrivate>&& privateStream) mutable {
+ auto scopeExit = makeScopeExit([completionHandler = WTFMove(completionHandler)]() mutable {
+ completionHandler();
+ });
+ if (isContextStopped())
+ return;
- if (!privateStream) {
- RELEASE_LOG(MediaStream, "UserMediaRequest::allow failed to create media stream!");
- deny(MediaAccessDenialReason::HardwareError);
- return;
- }
+ if (!privateStream) {
+ RELEASE_LOG(MediaStream, "UserMediaRequest::allow failed to create media stream!");
+ deny(MediaAccessDenialReason::HardwareError);
+ return;
+ }
- auto& document = downcast<Document>(*m_scriptExecutionContext);
- privateStream->monitorOrientation(document.orientationNotifier());
+ auto& document = downcast<Document>(*m_scriptExecutionContext);
+ privateStream->monitorOrientation(document.orientationNotifier());
- auto stream = MediaStream::create(document, privateStream.releaseNonNull());
- stream->startProducingData();
+ auto stream = MediaStream::create(document, privateStream.releaseNonNull());
+ stream->startProducingData();
- if (!isMediaStreamCorrectlyStarted(stream)) {
- deny(MediaAccessDenialReason::HardwareError);
- return;
- }
+ if (!isMediaStreamCorrectlyStarted(stream)) {
+ deny(MediaAccessDenialReason::HardwareError);
+ return;
+ }
- ASSERT(document.isCapturing());
- stream->document()->setHasCaptureMediaStreamTrack();
- m_promise->resolve(WTFMove(stream));
- };
+ ASSERT(document.isCapturing());
+ stream->document()->setHasCaptureMediaStreamTrack();
+ m_promise->resolve(WTFMove(stream));
+ };
- auto& document = downcast<Document>(*scriptExecutionContext());
- document.setDeviceIDHashSalt(deviceIdentifierHashSalt);
+ auto& document = downcast<Document>(*scriptExecutionContext());
+ document.setDeviceIDHashSalt(deviceIdentifierHashSalt);
- RealtimeMediaSourceCenter::singleton().createMediaStream(document.logger(), WTFMove(callback), WTFMove(deviceIdentifierHashSalt), WTFMove(audioDevice), WTFMove(videoDevice), m_request);
+ RealtimeMediaSourceCenter::singleton().createMediaStream(document.logger(), WTFMove(callback), WTFMove(deviceIdentifierHashSalt), WTFMove(audioDevice), WTFMove(videoDevice), m_request);
- if (!m_scriptExecutionContext)
- return;
+ if (!m_scriptExecutionContext)
+ return;
#if ENABLE(WEB_RTC)
- if (auto* page = document.page())
- page->rtcController().disableICECandidateFilteringForDocument(document);
+ if (auto* page = document.page())
+ page->rtcController().disableICECandidateFilteringForDocument(document);
#endif
+ });
}
void UserMediaRequest::deny(MediaAccessDenialReason reason, const String& message)