Skip to content
Permalink
Browse files
Allow b/f cache in case of connected peer connections
https://bugs.webkit.org/show_bug.cgi?id=204583

Reviewed by Chris Dumez.

Source/WebCore:

Tests: webrtc/peerconnection-page-cache-long.html
       webrtc/peerconnection-page-cache.html

Remove guards against b/f cache.
When entering b/f cache, the packets are blocked which will trigger timeouts
and a connection failure of the peer connection after a few seconds.

* Modules/mediastream/RTCDTMFSender.cpp:
* Modules/mediastream/RTCDTMFSender.h:
* Modules/mediastream/RTCDataChannel.h:
* Modules/mediastream/RTCPeerConnection.cpp:
* Modules/mediastream/RTCPeerConnection.h:

LayoutTests:

* fast/history/resources/page-cache-helper-10000ms.html: Added.
* webrtc/peerconnection-page-cache-expected.txt: Added.
* webrtc/peerconnection-page-cache-long-expected.txt: Added.
* webrtc/peerconnection-page-cache-long.html: Added.
* webrtc/peerconnection-page-cache.html: Added.


Canonical link: https://commits.webkit.org/217863@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252889 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf committed Nov 26, 2019
1 parent 6580138 commit e9730e9049efad97ef785c3f0195a43a9cbf21f8
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 17 deletions.
@@ -1,3 +1,16 @@
2019-11-26 youenn fablet <youenn@apple.com>

Allow b/f cache in case of connected peer connections
https://bugs.webkit.org/show_bug.cgi?id=204583

Reviewed by Chris Dumez.

* fast/history/resources/page-cache-helper-10000ms.html: Added.
* webrtc/peerconnection-page-cache-expected.txt: Added.
* webrtc/peerconnection-page-cache-long-expected.txt: Added.
* webrtc/peerconnection-page-cache-long.html: Added.
* webrtc/peerconnection-page-cache.html: Added.

2019-11-26 Alejandro G. Castro <alex@igalia.com>

[GTK][WPE] New tests crashing after added in the r251377
@@ -0,0 +1,9 @@
This page should go back. If a test outputs the contents of this
page, then the test page failed to enter the page cache.
<script>
window.addEventListener("load", function() {
setTimeout(function() {
history.back();
}, 10000);
}, false);
</script>
@@ -0,0 +1,4 @@


PASS peerconnection-page-cache

@@ -0,0 +1,4 @@


PASS peerconnection-page-cache-long

@@ -0,0 +1,63 @@
<!-- webkit-test-runner [ enableBackForwardCache=true ] -->
<!DOCTYPE html>
<html>
<body>
<video id="video" autoplay=""></video>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="routines.js"></script>
<script>
t = async_test();

window.addEventListener("pageshow", async function(event) {
if (!event.persisted)
return;
assert_equals(t.pc1.connectionState, "disconnected");

t.pc1.onconnectionstatechange = () => {
if (t.pc1.connectionState === "connected")
t.done();
}

t.pc1.onicecandidate = (e) => t.pc2.addIceCandidate(e.candidate);
t.pc2.onicecandidate = (e) => t.pc1.addIceCandidate(e.candidate);

const offer = await t.pc1.createOffer();
await t.pc1.setLocalDescription(offer);
await t.pc2.setRemoteDescription(offer);

const answer = await t.pc2.createAnswer();
await t.pc2.setLocalDescription(answer);
await t.pc1.setRemoteDescription(answer);
});

window.addEventListener("pagehide", t.step_func((event) => {
assert_equals(t.pc1.connectionState, "connected");
if (!event.persisted)
assert_uneached("Page failed to enter page cache");

}));

onload = () => {
setTimeout(async () => {
const localStream = await navigator.mediaDevices.getUserMedia({ video: true });
const stream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
t.pc1 = firstConnection;
firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
}, (secondConnection) => {
t.pc2 = secondConnection;
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
});
setTimeout(() => reject("Test timed out"), 5000);
});
video.srcObject = stream;
await video.play();

window.location = "../fast/history/resources/page-cache-helper-10000ms.html";
}, 0);
};
</script>
</html>
@@ -0,0 +1,48 @@
<!-- webkit-test-runner [ enableBackForwardCache=true ] -->
<!DOCTYPE html>
<html>
<body>
<video id="video" autoplay=""></video>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="routines.js"></script>
<script>
t = async_test();

window.addEventListener("pageshow", function(event) {
if (!event.persisted)
return;
assert_equals(t.pc1.connectionState, "connected");
t.done();
});

window.addEventListener("pagehide", t.step_func((event) => {
assert_equals(t.pc1.connectionState, "connected");
if (!event.persisted)
assert_uneached("Page failed to enter page cache");

}));

onload = () => {
setTimeout(async () => {
const localStream = await navigator.mediaDevices.getUserMedia({video: true });
const stream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
t.pc1 = firstConnection;
firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
}, (secondConnection) => {
t.pc2 = secondConnection;
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
});
setTimeout(() => reject("Test timed out"), 5000);
});
video.srcObject = stream;
await video.play();

window.location = "../fast/history/resources/page-cache-helper.html";
}, 0);
};
</script>
</html>
@@ -1,3 +1,23 @@
2019-11-26 youenn fablet <youenn@apple.com>

Allow b/f cache in case of connected peer connections
https://bugs.webkit.org/show_bug.cgi?id=204583

Reviewed by Chris Dumez.

Tests: webrtc/peerconnection-page-cache-long.html
webrtc/peerconnection-page-cache.html

Remove guards against b/f cache.
When entering b/f cache, the packets are blocked which will trigger timeouts
and a connection failure of the peer connection after a few seconds.

* Modules/mediastream/RTCDTMFSender.cpp:
* Modules/mediastream/RTCDTMFSender.h:
* Modules/mediastream/RTCDataChannel.h:
* Modules/mediastream/RTCPeerConnection.cpp:
* Modules/mediastream/RTCPeerConnection.h:

2019-11-26 Antti Koivisto <antti@apple.com>

[LFC] Don't leak Boxes
@@ -148,12 +148,6 @@ const char* RTCDTMFSender::activeDOMObjectName() const
return "RTCDTMFSender";
}

// FIXME: This should never prevent entering the back/forward cache.
bool RTCDTMFSender::shouldPreventEnteringBackForwardCache_DEPRECATED() const
{
return m_sender && !m_sender->isStopped();
}

} // namespace WebCore

#endif // ENABLE(WEB_RTC)
@@ -58,7 +58,6 @@ class RTCDTMFSender final : public RefCounted<RTCDTMFSender>, public EventTarget

void stop() final;
const char* activeDOMObjectName() const final;
bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final;

EventTargetInterface eventTargetInterface() const final { return RTCDTMFSenderEventTargetInterfaceType; }
ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
@@ -95,9 +95,6 @@ class RTCDataChannel final : public ActiveDOMObject, public RTCDataChannelHandle
void stop() final;
const char* activeDOMObjectName() const final { return "RTCDataChannel"; }

// FIXME: This should never prevent entering the back/forward cache.
bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final { return m_readyState == RTCDataChannelState::Open; }

// RTCDataChannelHandlerClient API
void didChangeReadyState(RTCDataChannelState) final;
void didReceiveStringData(const String&) final;
@@ -498,12 +498,6 @@ const char* RTCPeerConnection::activeDOMObjectName() const
return "RTCPeerConnection";
}

// FIXME: This should never prevent entering the back/forward cache.
bool RTCPeerConnection::shouldPreventEnteringBackForwardCache_DEPRECATED() const
{
return m_iceConnectionState == RTCIceConnectionState::Completed || m_iceConnectionState == RTCIceConnectionState::Connected;
}

void RTCPeerConnection::suspend(ReasonForSuspension reason)
{
if (reason != ReasonForSuspension::BackForwardCache)
@@ -211,7 +211,6 @@ class RTCPeerConnection final
// ActiveDOMObject
WEBCORE_EXPORT void stop() final;
const char* activeDOMObjectName() const final;
bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final;
void suspend(ReasonForSuspension) final;
void resume() final;

0 comments on commit e9730e9

Please sign in to comment.