Changeset 252178 in webkit
- Timestamp:
- Nov 7, 2019 12:06:07 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252176 r252178 1 2019-11-05 Sergio Villar Senin <svillar@igalia.com> 2 3 VRDisplay should not prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203105 5 6 Reviewed by Chris Dumez. 7 8 VRDisplay schedules asynchronous execution of events using the WindowEventLoop instead of 9 synchronously firing them. WindowEventLoop does correctly suspend while in cache. 10 11 Apart from that suspend()/resume() were implemented by forcing m_scriptedAnimationController 12 to suspend the VR request animation frame machinery while in cache. 13 14 Last but not least, stopPresenting() is now also called on suspension. 15 16 No new tests were added as there is no testing machinery for WebVR so far. It's unclear how 17 this unreleased feature will evolve as it's being replaced by WebXR. 18 19 * Modules/webvr/VRDisplay.cpp: 20 (WebCore::VRDisplay::dispatchVRDisplayEventInWindowEventLoop): 21 (WebCore::VRDisplay::platformDisplayConnected): Use dispatchVRDisplayEventInWindowEventLoop. 22 (WebCore::VRDisplay::platformDisplayDisconnected): Ditto. 23 (WebCore::VRDisplay::platformDisplayMounted): Ditto. 24 (WebCore::VRDisplay::platformDisplayUnmounted): Ditto. 25 (WebCore::VRDisplay::suspend): Added. 26 (WebCore::VRDisplay::resume): Added. 27 (WebCore::VRDisplay::stop): Call stopPresenting(). 28 (WebCore::VRDisplay::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted. 29 * Modules/webvr/VRDisplay.h: 30 1 31 2019-11-06 Devin Rousso <drousso@apple.com> 2 32 -
trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp
r251244 r252178 44 44 #include "VRPose.h" 45 45 #include "VRStageParameters.h" 46 #include "WindowEventLoop.h" 46 47 #include <wtf/IsoMallocInlines.h> 47 48 … … 210 211 } 211 212 213 // Use a EventLoop instead of dispatching events synchronously because the 214 // EventLoop correctly suspends when in the cache. This way VRDisplay does no 215 // longer prevent caching in the back/forward cache. 216 void VRDisplay::dispatchVRDisplayEventInEventLoop(const AtomString& eventName, Optional<VRDisplayEventReason>&& reason) 217 { 218 auto event = VRDisplayEvent::create(eventName, makeRefPtr(this), WTFMove(reason)); 219 queueTaskKeepingObjectAlive(*this, TaskSource::UserInteraction, [this, event = WTFMove(event)]() mutable { 220 if (!document()) 221 return; 222 if (auto* window = document()->domWindow()) 223 window->dispatchEvent(event); 224 }); 225 } 226 212 227 void VRDisplay::platformDisplayConnected() 213 228 { 214 d ocument()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplayconnectEvent, makeRefPtr(this), WTF::nullopt));229 dispatchVRDisplayEventInEventLoop(eventNames().vrdisplayconnectEvent, WTF::nullopt); 215 230 } 216 231 217 232 void VRDisplay::platformDisplayDisconnected() 218 233 { 219 d ocument()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplaydisconnectEvent, makeRefPtr(this), WTF::nullopt));234 dispatchVRDisplayEventInEventLoop(eventNames().vrdisplaydisconnectEvent, WTF::nullopt); 220 235 } 221 236 222 237 void VRDisplay::platformDisplayMounted() 223 238 { 224 d ocument()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplayactivateEvent, makeRefPtr(this), VRDisplayEventReason::Mounted));239 dispatchVRDisplayEventInEventLoop(eventNames().vrdisplayactivateEvent, VRDisplayEventReason::Mounted); 225 240 } 226 241 227 242 void VRDisplay::platformDisplayUnmounted() 228 243 { 229 d ocument()->domWindow()->dispatchEvent(VRDisplayEvent::create(eventNames().vrdisplaydeactivateEvent, makeRefPtr(this), VRDisplayEventReason::Unmounted));244 dispatchVRDisplayEventInEventLoop(eventNames().vrdisplaydeactivateEvent, VRDisplayEventReason::Unmounted); 230 245 } 231 246 … … 240 255 } 241 256 242 // FIXME: This should never prevent entering the back/forward cache. 243 bool VRDisplay::shouldPreventEnteringBackForwardCache_DEPRECATED() const 244 { 245 return true; 257 void VRDisplay::suspend(ReasonForSuspension reason) 258 { 259 if (m_scriptedAnimationController) 260 m_scriptedAnimationController->suspend(); 261 if (reason == ReasonForSuspension::BackForwardCache) 262 stopPresenting(); 263 } 264 265 void VRDisplay::resume() 266 { 267 if (m_scriptedAnimationController) 268 m_scriptedAnimationController->resume(); 246 269 } 247 270 248 271 void VRDisplay::stop() 249 272 { 273 m_scriptedAnimationController = nullptr; 274 stopPresenting(); 250 275 } 251 276 -
trunk/Source/WebCore/Modules/webvr/VRDisplay.h
r251244 r252178 28 28 #include "ActiveDOMObject.h" 29 29 #include "EventTarget.h" 30 #include "VRDisplayEventReason.h" 30 31 #include "VREye.h" 31 32 #include "VRLayerInit.h" 32 33 #include "VRPlatformDisplayClient.h" 34 #include <wtf/Optional.h> 33 35 #include <wtf/RefCounted.h> 34 36 … … 107 109 // ActiveDOMObject 108 110 const char* activeDOMObjectName() const override; 109 bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override; 111 void suspend(ReasonForSuspension) override; 112 void resume() override; 110 113 void stop() override; 111 114 … … 113 116 114 117 Document* document() { return downcast<Document>(scriptExecutionContext()); } 118 119 void dispatchVRDisplayEventInEventLoop(const AtomString& eventName, Optional<VRDisplayEventReason>&&); 115 120 116 121 WeakPtr<VRPlatformDisplay> m_display;
Note: See TracChangeset
for help on using the changeset viewer.