Title: [265623] trunk/Source
Revision
265623
Author
[email protected]
Date
2020-08-13 14:50:31 -0700 (Thu, 13 Aug 2020)

Log Message

REGRESSION (r260684): Messages YouTube inline video: after Multitasking away and Back, Audio is heard but icon indicates "muted"
https://bugs.webkit.org/show_bug.cgi?id=215453
<rdar://problem/66136673>

Reviewed by Tim Horton.

Source/WebCore:

r260684 silenced all JS events during the snapshot sequence that occurs whenever the user homes out of Safari.
This was meant to address compatibility with websites that did not expect various resize/orientationchange
events when homing out. However, the snapshot sequence is fairly long and this was causing us to silence JS
events which have nothing to do with the snapshot sequence, like window.postMessage()'s message events. This is
what caused this regression.

To address the issue, this patch basically reverts r260684 and deals with websites-compatibility issues via
less risky site-specific and event-specific quirks:
- We silence Window resize events on nytimes.com to address <rdar://problem/59763843>.
- We silence Window resize events and MediaQueryList change events on twitter.com to address <rdar://problem/58804852>
  and <rdar://problem/61731801>.

* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::evaluateAll):
* dom/EventTarget.cpp:
(WebCore::EventTarget::fireEventListeners):
* page/FrameView.cpp:
(WebCore::FrameView::sendResizeEventIfNeeded):
* page/Page.h:
(WebCore::Page::isTakingSnapshotsForApplicationSuspension const):
(WebCore::Page::setIsTakingSnapshotsForApplicationSuspension):
(WebCore::Page::shouldFireEvents const): Deleted.
(WebCore::Page::setShouldFireEvents): Deleted.
* page/Quirks.cpp:
(WebCore::Quirks::shouldSilenceWindowResizeEvents const):
(WebCore::Quirks::shouldSilenceMediaQueryListChangeEvents const):
* page/Quirks.h:

Source/WebKit:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setIsDoingSnapshotSequence):
(WebKit::WebPageProxy::setShouldFireEvents): Deleted.
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKApplicationStateTrackingView.mm:
(-[WKApplicationStateTrackingView _willBeginSnapshotSequence]):
(-[WKApplicationStateTrackingView _didCompleteSnapshotSequence]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setIsDoingSnapshotSequence):
(WebKit::WebPage::setShouldFireEvents): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (265622 => 265623)


--- trunk/Source/WebCore/ChangeLog	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebCore/ChangeLog	2020-08-13 21:50:31 UTC (rev 265623)
@@ -1,3 +1,39 @@
+2020-08-13  Chris Dumez  <[email protected]>
+
+        REGRESSION (r260684): Messages YouTube inline video: after Multitasking away and Back, Audio is heard but icon indicates "muted"
+        https://bugs.webkit.org/show_bug.cgi?id=215453
+        <rdar://problem/66136673>
+
+        Reviewed by Tim Horton.
+
+        r260684 silenced all JS events during the snapshot sequence that occurs whenever the user homes out of Safari.
+        This was meant to address compatibility with websites that did not expect various resize/orientationchange
+        events when homing out. However, the snapshot sequence is fairly long and this was causing us to silence JS
+        events which have nothing to do with the snapshot sequence, like window.postMessage()'s message events. This is
+        what caused this regression.
+
+        To address the issue, this patch basically reverts r260684 and deals with websites-compatibility issues via
+        less risky site-specific and event-specific quirks:
+        - We silence Window resize events on nytimes.com to address <rdar://problem/59763843>.
+        - We silence Window resize events and MediaQueryList change events on twitter.com to address <rdar://problem/58804852>
+          and <rdar://problem/61731801>.
+
+        * css/MediaQueryMatcher.cpp:
+        (WebCore::MediaQueryMatcher::evaluateAll):
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::fireEventListeners):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::sendResizeEventIfNeeded):
+        * page/Page.h:
+        (WebCore::Page::isTakingSnapshotsForApplicationSuspension const):
+        (WebCore::Page::setIsTakingSnapshotsForApplicationSuspension):
+        (WebCore::Page::shouldFireEvents const): Deleted.
+        (WebCore::Page::setShouldFireEvents): Deleted.
+        * page/Quirks.cpp:
+        (WebCore::Quirks::shouldSilenceWindowResizeEvents const):
+        (WebCore::Quirks::shouldSilenceMediaQueryListChangeEvents const):
+        * page/Quirks.h:
+
 2020-08-13  Aditya Keerthi  <[email protected]>
 
         [macOS] Zoomed-in search field is clipped out

Modified: trunk/Source/WebCore/css/MediaQueryMatcher.cpp (265622 => 265623)


--- trunk/Source/WebCore/css/MediaQueryMatcher.cpp	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebCore/css/MediaQueryMatcher.cpp	2020-08-13 21:50:31 UTC (rev 265623)
@@ -125,8 +125,12 @@
             continue;
         bool notify;
         list->evaluate(evaluator, notify);
-        if (notify)
+        if (notify) {
+            if (m_document && m_document->quirks().shouldSilenceMediaQueryListChangeEvents())
+                continue;
+
             list->dispatchEvent(MediaQueryListEvent::create(eventNames().changeEvent, list->media(), list->matches()));
+        }
     }
 }
 

Modified: trunk/Source/WebCore/dom/EventTarget.cpp (265622 => 265623)


--- trunk/Source/WebCore/dom/EventTarget.cpp	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebCore/dom/EventTarget.cpp	2020-08-13 21:50:31 UTC (rev 265623)
@@ -258,15 +258,6 @@
     if (!data)
         return;
 
-    // FIXME: Remove once <rdar://problem/62344280> is fixed.
-    if (is<Document>(scriptExecutionContext())) {
-        auto* page = downcast<Document>(*scriptExecutionContext()).page();
-        if (page && !page->shouldFireEvents()) {
-            RELEASE_LOG_IF(page->isAlwaysOnLoggingAllowed(), Events, "%p - EventTarget::fireEventListeners: Not firing %{public}s event because events are temporarily disabled for this page", this, event.type().string().utf8().data());
-            return;
-        }
-    }
-
     SetForScope<bool> firingEventListenersScope(data->isFiringEventListeners, true);
 
     if (auto* listenersVector = data->eventListenerMap.find(event.type())) {

Modified: trunk/Source/WebCore/page/FrameView.cpp (265622 => 265623)


--- trunk/Source/WebCore/page/FrameView.cpp	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebCore/page/FrameView.cpp	2020-08-13 21:50:31 UTC (rev 265623)
@@ -72,6 +72,7 @@
 #include "Page.h"
 #include "PageOverlayController.h"
 #include "ProgressTracker.h"
+#include "Quirks.h"
 #include "RenderEmbeddedObject.h"
 #include "RenderFullScreen.h"
 #include "RenderIFrame.h"
@@ -3391,9 +3392,15 @@
     }
 #endif
 
-    LOG_WITH_STREAM(Events, stream << "FrameView" << this << "sendResizeEventIfNeeded scheduling resize event for document" << frame().document() << ", size " << currentSize);
-    frame().document()->setNeedsDOMWindowResizeEvent();
+    auto* document = frame().document();
+    if (document->quirks().shouldSilenceWindowResizeEvents()) {
+        FRAMEVIEW_RELEASE_LOG_IF_ALLOWED(Events, "sendResizeEventIfNeeded: Not firing resize events because they are temporarily disabled for this page");
+        return;
+    }
 
+    LOG_WITH_STREAM(Events, stream << "FrameView" << this << "sendResizeEventIfNeeded scheduling resize event for document" << document << ", size " << currentSize);
+    document->setNeedsDOMWindowResizeEvent();
+
     bool isMainFrame = frame().isMainFrame();
     if (InspectorInstrumentation::hasFrontends() && isMainFrame) {
         if (InspectorClient* inspectorClient = page ? page->inspectorController().inspectorClient() : nullptr)

Modified: trunk/Source/WebCore/page/Page.h (265622 => 265623)


--- trunk/Source/WebCore/page/Page.h	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebCore/page/Page.h	2020-08-13 21:50:31 UTC (rev 265623)
@@ -773,8 +773,8 @@
     WEBCORE_EXPORT void injectUserStyleSheet(UserStyleSheet&);
     WEBCORE_EXPORT void removeInjectedUserStyleSheet(UserStyleSheet&);
 
-    bool shouldFireEvents() const { return m_shouldFireEvents; }
-    void setShouldFireEvents(bool shouldFireEvents) { m_shouldFireEvents = shouldFireEvents; }
+    bool isTakingSnapshotsForApplicationSuspension() const { return m_isTakingSnapshotsForApplicationSuspension; }
+    void setIsTakingSnapshotsForApplicationSuspension(bool isTakingSnapshotsForApplicationSuspension) { m_isTakingSnapshotsForApplicationSuspension = isTakingSnapshotsForApplicationSuspension; }
 
     bool hasBeenNotifiedToInjectUserScripts() const { return m_hasBeenNotifiedToInjectUserScripts; }
     WEBCORE_EXPORT void notifyToInjectUserScripts();
@@ -1067,7 +1067,7 @@
 
     Vector<UserContentURLPattern> m_corsDisablingPatterns;
     Vector<UserStyleSheet> m_userStyleSheetsPendingInjection;
-    bool m_shouldFireEvents { true };
+    bool m_isTakingSnapshotsForApplicationSuspension { false };
     bool m_loadsSubresources { true };
     bool m_loadsFromNetwork { true };
     bool m_canUseCredentialStorage { true };

Modified: trunk/Source/WebCore/page/Quirks.cpp (265622 => 265623)


--- trunk/Source/WebCore/page/Quirks.cpp	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebCore/page/Quirks.cpp	2020-08-13 21:50:31 UTC (rev 265623)
@@ -643,6 +643,46 @@
 #endif
 }
 
+bool Quirks::shouldSilenceWindowResizeEvents() const
+{
+#if PLATFORM(IOS)
+    if (!needsQuirks())
+        return false;
+
+    // We silence window resize events during the 'homing out' snapshot sequence when on nytimes.com
+    // to address <rdar://problem/59763843>, and on twitter.com to address <rdar://problem/58804852> &
+    // <rdar://problem/61731801>.
+    auto* page = m_document->page();
+    if (!page || !page->isTakingSnapshotsForApplicationSuspension())
+        return false;
+
+    auto host = m_document->topDocument().url().host();
+    return equalLettersIgnoringASCIICase(host, "nytimes.com") || host.endsWithIgnoringASCIICase(".nytimes.com")
+        || equalLettersIgnoringASCIICase(host, "twitter.com") || host.endsWithIgnoringASCIICase(".twitter.com");
+#else
+    return false;
+#endif
+}
+
+bool Quirks::shouldSilenceMediaQueryListChangeEvents() const
+{
+#if PLATFORM(IOS)
+    if (!needsQuirks())
+        return false;
+
+    // We silence MediaQueryList's change events during the 'homing out' snapshot sequence when on twitter.com
+    // to address <rdar://problem/58804852> & <rdar://problem/61731801>.
+    auto* page = m_document->page();
+    if (!page || !page->isTakingSnapshotsForApplicationSuspension())
+        return false;
+
+    auto host = m_document->topDocument().url().host();
+    return equalLettersIgnoringASCIICase(host, "twitter.com") || host.endsWithIgnoringASCIICase(".twitter.com");
+#else
+    return false;
+#endif
+}
+
 bool Quirks::shouldAvoidScrollingWhenFocusedContentIsVisible() const
 {
     if (!needsQuirks())

Modified: trunk/Source/WebCore/page/Quirks.h (265622 => 265623)


--- trunk/Source/WebCore/page/Quirks.h	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebCore/page/Quirks.h	2020-08-13 21:50:31 UTC (rev 265623)
@@ -44,6 +44,8 @@
     Quirks(Document&);
     ~Quirks();
 
+    bool shouldSilenceWindowResizeEvents() const;
+    bool shouldSilenceMediaQueryListChangeEvents() const;
     bool shouldIgnoreInvalidSignal() const;
     bool needsFormControlToBeMouseFocusable() const;
     bool needsAutoplayPlayPauseEvents() const;

Modified: trunk/Source/WebKit/ChangeLog (265622 => 265623)


--- trunk/Source/WebKit/ChangeLog	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebKit/ChangeLog	2020-08-13 21:50:31 UTC (rev 265623)
@@ -1,3 +1,24 @@
+2020-08-13  Chris Dumez  <[email protected]>
+
+        REGRESSION (r260684): Messages YouTube inline video: after Multitasking away and Back, Audio is heard but icon indicates "muted"
+        https://bugs.webkit.org/show_bug.cgi?id=215453
+        <rdar://problem/66136673>
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setIsDoingSnapshotSequence):
+        (WebKit::WebPageProxy::setShouldFireEvents): Deleted.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKApplicationStateTrackingView.mm:
+        (-[WKApplicationStateTrackingView _willBeginSnapshotSequence]):
+        (-[WKApplicationStateTrackingView _didCompleteSnapshotSequence]):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setIsDoingSnapshotSequence):
+        (WebKit::WebPage::setShouldFireEvents): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2020-08-13  Per Arne Vollan  <[email protected]>
 
         Unreviewed, reverting r265520.

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (265622 => 265623)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-08-13 21:50:31 UTC (rev 265623)
@@ -10152,9 +10152,9 @@
     send(Messages::WebPage::SetOverriddenMediaType(mediaType));
 }
 
-void WebPageProxy::setShouldFireEvents(bool shouldFireEvents)
+void WebPageProxy::setIsTakingSnapshotsForApplicationSuspension(bool isTakingSnapshotsForApplicationSuspension)
 {
-    send(Messages::WebPage::SetShouldFireEvents(shouldFireEvents));
+    send(Messages::WebPage::SetIsTakingSnapshotsForApplicationSuspension(isTakingSnapshotsForApplicationSuspension));
 }
 
 void WebPageProxy::setNeedsDOMWindowResizeEvent()

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (265622 => 265623)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-08-13 21:50:31 UTC (rev 265623)
@@ -1756,7 +1756,7 @@
     void grantAccessToPreferenceService();
 #endif
 
-    void setShouldFireEvents(bool);
+    void setIsTakingSnapshotsForApplicationSuspension(bool);
     void setNeedsDOMWindowResizeEvent();
 
     void isNavigatingToAppBoundDomainTesting(CompletionHandler<void(bool)>&&);

Modified: trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm (265622 => 265623)


--- trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm	2020-08-13 21:50:31 UTC (rev 265623)
@@ -109,7 +109,7 @@
     if (!page)
         return;
 
-    page->setShouldFireEvents(false);
+    page->setIsTakingSnapshotsForApplicationSuspension(true);
 }
 
 - (void)_didCompleteSnapshotSequence
@@ -118,7 +118,7 @@
     if (!page)
         return;
 
-    page->setShouldFireEvents(true);
+    page->setIsTakingSnapshotsForApplicationSuspension(false);
 }
 
 - (BOOL)isBackground

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (265622 => 265623)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-08-13 21:50:31 UTC (rev 265623)
@@ -3372,12 +3372,12 @@
     send(Messages::WebPageProxy::ShowPage());
 }
 
-void WebPage::setShouldFireEvents(bool shouldFireEvents)
+void WebPage::setIsTakingSnapshotsForApplicationSuspension(bool isTakingSnapshotsForApplicationSuspension)
 {
-    RELEASE_LOG_IF_ALLOWED(Resize, "setShouldFireEvents(%d)", shouldFireEvents);
+    RELEASE_LOG_IF_ALLOWED(Resize, "setIsTakingSnapshotsForApplicationSuspension(%d)", isTakingSnapshotsForApplicationSuspension);
 
     if (m_page)
-        m_page->setShouldFireEvents(shouldFireEvents);
+        m_page->setIsTakingSnapshotsForApplicationSuspension(isTakingSnapshotsForApplicationSuspension);
 }
 
 void WebPage::setNeedsDOMWindowResizeEvent()

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (265622 => 265623)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-08-13 21:50:31 UTC (rev 265623)
@@ -1731,7 +1731,7 @@
     void urlSchemeTaskDidReceiveData(uint64_t handlerIdentifier, uint64_t taskIdentifier, const IPC::SharedBufferDataReference&);
     void urlSchemeTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, const WebCore::ResourceError&);
 
-    void setShouldFireEvents(bool);
+    void setIsTakingSnapshotsForApplicationSuspension(bool);
     void setNeedsDOMWindowResizeEvent();
 
     void setIsSuspended(bool);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (265622 => 265623)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-08-13 21:42:32 UTC (rev 265622)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-08-13 21:50:31 UTC (rev 265623)
@@ -605,7 +605,7 @@
 
     UpdateCORSDisablingPatterns(Vector<String> patterns)
 
-    SetShouldFireEvents(bool shouldFireEvents)
+    SetIsTakingSnapshotsForApplicationSuspension(bool isTakingSnapshotsForApplicationSuspension)
     SetNeedsDOMWindowResizeEvent()
 
     SetHasResourceLoadClient(bool has)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to