Title: [252178] trunk/Source/WebCore
- Revision
- 252178
- Author
- [email protected]
- Date
- 2019-11-07 00:06:07 -0800 (Thu, 07 Nov 2019)
Log Message
VRDisplay should not prevent entering the back/forward cache
https://bugs.webkit.org/show_bug.cgi?id=203105
Reviewed by Chris Dumez.
VRDisplay schedules asynchronous execution of events using the WindowEventLoop instead of
synchronously firing them. WindowEventLoop does correctly suspend while in cache.
Apart from that suspend()/resume() were implemented by forcing m_scriptedAnimationController
to suspend the VR request animation frame machinery while in cache.
Last but not least, stopPresenting() is now also called on suspension.
No new tests were added as there is no testing machinery for WebVR so far. It's unclear how
this unreleased feature will evolve as it's being replaced by WebXR.
* Modules/webvr/VRDisplay.cpp:
(WebCore::VRDisplay::dispatchVRDisplayEventInWindowEventLoop):
(WebCore::VRDisplay::platformDisplayConnected): Use dispatchVRDisplayEventInWindowEventLoop.
(WebCore::VRDisplay::platformDisplayDisconnected): Ditto.
(WebCore::VRDisplay::platformDisplayMounted): Ditto.
(WebCore::VRDisplay::platformDisplayUnmounted): Ditto.
(WebCore::VRDisplay::suspend): Added.
(WebCore::VRDisplay::resume): Added.
(WebCore::VRDisplay::stop): Call stopPresenting().
(WebCore::VRDisplay::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted.
* Modules/webvr/VRDisplay.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (252177 => 252178)
--- trunk/Source/WebCore/ChangeLog 2019-11-07 07:27:52 UTC (rev 252177)
+++ trunk/Source/WebCore/ChangeLog 2019-11-07 08:06:07 UTC (rev 252178)
@@ -1,3 +1,33 @@
+2019-11-05 Sergio Villar Senin <[email protected]>
+
+ VRDisplay should not prevent entering the back/forward cache
+ https://bugs.webkit.org/show_bug.cgi?id=203105
+
+ Reviewed by Chris Dumez.
+
+ VRDisplay schedules asynchronous execution of events using the WindowEventLoop instead of
+ synchronously firing them. WindowEventLoop does correctly suspend while in cache.
+
+ Apart from that suspend()/resume() were implemented by forcing m_scriptedAnimationController
+ to suspend the VR request animation frame machinery while in cache.
+
+ Last but not least, stopPresenting() is now also called on suspension.
+
+ No new tests were added as there is no testing machinery for WebVR so far. It's unclear how
+ this unreleased feature will evolve as it's being replaced by WebXR.
+
+ * Modules/webvr/VRDisplay.cpp:
+ (WebCore::VRDisplay::dispatchVRDisplayEventInWindowEventLoop):
+ (WebCore::VRDisplay::platformDisplayConnected): Use dispatchVRDisplayEventInWindowEventLoop.
+ (WebCore::VRDisplay::platformDisplayDisconnected): Ditto.
+ (WebCore::VRDisplay::platformDisplayMounted): Ditto.
+ (WebCore::VRDisplay::platformDisplayUnmounted): Ditto.
+ (WebCore::VRDisplay::suspend): Added.
+ (WebCore::VRDisplay::resume): Added.
+ (WebCore::VRDisplay::stop): Call stopPresenting().
+ (WebCore::VRDisplay::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted.
+ * Modules/webvr/VRDisplay.h:
+
2019-11-06 Devin Rousso <[email protected]>
Remove unimplemented property error log in when getting a property value from a computed style
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp (252177 => 252178)
--- trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp 2019-11-07 07:27:52 UTC (rev 252177)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp 2019-11-07 08:06:07 UTC (rev 252178)
@@ -43,6 +43,7 @@
#include "VRPlatformDisplay.h"
#include "VRPose.h"
#include "VRStageParameters.h"
+#include "WindowEventLoop.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
@@ -209,24 +210,38 @@
{
}
+// Use a EventLoop instead of dispatching events synchronously because the
+// EventLoop correctly suspends when in the cache. This way VRDisplay does no
+// longer prevent caching in the back/forward cache.
+void VRDisplay::dispatchVRDisplayEventInEventLoop(const AtomString& eventName, Optional<VRDisplayEventReason>&& reason)
+{
+ auto event = VRDisplayEvent::create(eventName, makeRefPtr(this), WTFMove(reason));
+ queueTaskKeepingObjectAlive(*this, TaskSource::UserInteraction, [this, event = WTFMove(event)]() mutable {
+ if (!document())
+ return;
+ if (auto* window = document()->domWindow())
+ window->dispatchEvent(event);
+ });
+}
+
void VRDisplay::platformDisplayConnected()
{
- document()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplayconnectEvent, makeRefPtr(this), WTF::nullopt));
+ dispatchVRDisplayEventInEventLoop(eventNames().vrdisplayconnectEvent, WTF::nullopt);
}
void VRDisplay::platformDisplayDisconnected()
{
- document()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplaydisconnectEvent, makeRefPtr(this), WTF::nullopt));
+ dispatchVRDisplayEventInEventLoop(eventNames().vrdisplaydisconnectEvent, WTF::nullopt);
}
void VRDisplay::platformDisplayMounted()
{
- document()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplayactivateEvent, makeRefPtr(this), VRDisplayEventReason::Mounted));
+ dispatchVRDisplayEventInEventLoop(eventNames().vrdisplayactivateEvent, VRDisplayEventReason::Mounted);
}
void VRDisplay::platformDisplayUnmounted()
{
- document()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplaydeactivateEvent, makeRefPtr(this), VRDisplayEventReason::Unmounted));
+ dispatchVRDisplayEventInEventLoop(eventNames().vrdisplaydeactivateEvent, VRDisplayEventReason::Unmounted);
}
bool VRDisplay::hasPendingActivity() const
@@ -239,14 +254,24 @@
return "VRDisplay";
}
-// FIXME: This should never prevent entering the back/forward cache.
-bool VRDisplay::shouldPreventEnteringBackForwardCache_DEPRECATED() const
+void VRDisplay::suspend(ReasonForSuspension reason)
{
- return true;
+ if (m_scriptedAnimationController)
+ m_scriptedAnimationController->suspend();
+ if (reason == ReasonForSuspension::BackForwardCache)
+ stopPresenting();
}
+void VRDisplay::resume()
+{
+ if (m_scriptedAnimationController)
+ m_scriptedAnimationController->resume();
+}
+
void VRDisplay::stop()
{
+ m_scriptedAnimationController = nullptr;
+ stopPresenting();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplay.h (252177 => 252178)
--- trunk/Source/WebCore/Modules/webvr/VRDisplay.h 2019-11-07 07:27:52 UTC (rev 252177)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplay.h 2019-11-07 08:06:07 UTC (rev 252178)
@@ -27,9 +27,11 @@
#include "ActiveDOMObject.h"
#include "EventTarget.h"
+#include "VRDisplayEventReason.h"
#include "VREye.h"
#include "VRLayerInit.h"
#include "VRPlatformDisplayClient.h"
+#include <wtf/Optional.h>
#include <wtf/RefCounted.h>
namespace WebCore {
@@ -106,7 +108,8 @@
// ActiveDOMObject
const char* activeDOMObjectName() const override;
- bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override;
+ void suspend(ReasonForSuspension) override;
+ void resume() override;
void stop() override;
void stopPresenting();
@@ -113,6 +116,8 @@
Document* document() { return downcast<Document>(scriptExecutionContext()); }
+ void dispatchVRDisplayEventInEventLoop(const AtomString& eventName, Optional<VRDisplayEventReason>&&);
+
WeakPtr<VRPlatformDisplay> m_display;
RefPtr<VRDisplayCapabilities> m_capabilities;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes