Title: [255582] trunk/Source/WebCore
Revision
255582
Author
you...@apple.com
Date
2020-02-03 12:44:49 -0800 (Mon, 03 Feb 2020)

Log Message

[ macOS wk2 ] http/tests/media/media-stream/get-display-media-prompt.html is flaky failure
https://bugs.webkit.org/show_bug.cgi?id=206958
<rdar://problem/59003765>

Reviewed by Eric Carlson.

We added a rule to only allow one getDisplayMedia call per gesture.
For that reason, we were storing a pointer to the gesture event and
resetting in case the current gesture event was equal to the stored pointer.
Instead, store a WeakPtr which ensures that if the previous event is destroyed,
the weak pointer will be null and so will not have the same value as the new gesture event.
Covered by existing tests no longer being flaky.

* Modules/mediastream/MediaDevices.cpp:
(WebCore::MediaDevices::computeUserGesturePriviledge):
* Modules/mediastream/MediaDevices.h:
* dom/UserGestureIndicator.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255581 => 255582)


--- trunk/Source/WebCore/ChangeLog	2020-02-03 20:19:44 UTC (rev 255581)
+++ trunk/Source/WebCore/ChangeLog	2020-02-03 20:44:49 UTC (rev 255582)
@@ -1,3 +1,23 @@
+2020-02-03  youenn fablet  <you...@apple.com>
+
+        [ macOS wk2 ] http/tests/media/media-stream/get-display-media-prompt.html is flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=206958
+        <rdar://problem/59003765>
+
+        Reviewed by Eric Carlson.
+
+        We added a rule to only allow one getDisplayMedia call per gesture.
+        For that reason, we were storing a pointer to the gesture event and
+        resetting in case the current gesture event was equal to the stored pointer.
+        Instead, store a WeakPtr which ensures that if the previous event is destroyed,
+        the weak pointer will be null and so will not have the same value as the new gesture event.
+        Covered by existing tests no longer being flaky.
+
+        * Modules/mediastream/MediaDevices.cpp:
+        (WebCore::MediaDevices::computeUserGesturePriviledge):
+        * Modules/mediastream/MediaDevices.h:
+        * dom/UserGestureIndicator.h:
+
 2020-02-03  Eric Carlson  <eric.carl...@apple.com>
 
         [macOS] AirPlay sometimes stops after 60 minutes of playback

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp (255581 => 255582)


--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp	2020-02-03 20:19:44 UTC (rev 255581)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp	2020-02-03 20:44:49 UTC (rev 255582)
@@ -109,8 +109,8 @@
 bool MediaDevices::computeUserGesturePriviledge(GestureAllowedRequest requestType)
 {
     auto* currentGestureToken = UserGestureIndicator::currentUserGesture().get();
-    if (m_currentGestureToken != currentGestureToken) {
-        m_currentGestureToken = currentGestureToken;
+    if (m_currentGestureToken.get() != currentGestureToken) {
+        m_currentGestureToken = makeWeakPtr(currentGestureToken);
         m_requestTypesForCurrentGesture = { };
     }
 

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.h (255581 => 255582)


--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.h	2020-02-03 20:19:44 UTC (rev 255581)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.h	2020-02-03 20:44:49 UTC (rev 255582)
@@ -125,7 +125,7 @@
     bool m_canAccessMicrophone { false };
 
     OptionSet<GestureAllowedRequest> m_requestTypesForCurrentGesture;
-    UserGestureToken* m_currentGestureToken { nullptr };
+    WeakPtr<UserGestureToken> m_currentGestureToken;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.h (255581 => 255582)


--- trunk/Source/WebCore/dom/UserGestureIndicator.h	2020-02-03 20:19:44 UTC (rev 255581)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.h	2020-02-03 20:44:49 UTC (rev 255582)
@@ -31,6 +31,7 @@
 #include <wtf/Noncopyable.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -44,7 +45,7 @@
 
 enum class UserGestureType { EscapeKey, Other };
 
-class UserGestureToken : public RefCounted<UserGestureToken> {
+class UserGestureToken : public RefCounted<UserGestureToken>, public CanMakeWeakPtr<UserGestureToken> {
 public:
     static Ref<UserGestureToken> create(ProcessingUserGestureState state, UserGestureType gestureType)
     {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to