RESOLVED FIXED 239781
Video playback fails when using postMessage() during a User Gesture
https://bugs.webkit.org/show_bug.cgi?id=239781
Summary Video playback fails when using postMessage() during a User Gesture
Jer Noble
Reported 2022-04-26 11:41:35 PDT
Video playback fails when using postMessage() during a User Gesture
Attachments
Patch (11.36 KB, patch)
2022-04-26 11:51 PDT, Jer Noble
no flags
Patch for landing (11.50 KB, patch)
2022-04-28 11:25 PDT, Jer Noble
no flags
Patch for landing (12.12 KB, patch)
2022-05-05 08:39 PDT, Jer Noble
no flags
Patch for landing (11.83 KB, patch)
2022-05-05 11:35 PDT, Jer Noble
no flags
Jer Noble
Comment 1 2022-04-26 11:42:09 PDT
Jer Noble
Comment 2 2022-04-26 11:51:42 PDT
Eric Carlson
Comment 3 2022-04-26 11:58:02 PDT
Comment on attachment 458386 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=458386&action=review > Source/WebCore/ChangeLog:12 > + Certain frameworks handle user gestures by sending messages through postMessage() to > + to a non-shared worker, where the message is processed and a response is sent back s/to to/to/ > LayoutTests/workers/worker-user-gesture.html:11 > + const mc = new MessageChannel(); > + const w = new Worker("worker-user-gesture.js"); Vowels are cheap, you should use some to name these variables.
youenn fablet
Comment 4 2022-04-26 23:34:19 PDT
Comment on attachment 458386 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=458386&action=review > Source/WebCore/workers/WorkerMessagingProxy.cpp:78 > + WorkerUserGestureForwarder(RefPtr<UserGestureToken>&& token) explicit. > Source/WebCore/workers/WorkerMessagingProxy.cpp:136 > + m_scriptExecutionContext->postTask([this, message = WTFMove(message), userGestureForwarder = m_userGestureForwarder] (ScriptExecutionContext& context) mutable { s/ScriptExecutionContext/auto/ > Source/WebCore/workers/WorkerMessagingProxy.cpp:143 > + UserGestureIndicator userGestureIndicator(userGestureForwarder ? userGestureForwarder->userGestureToForward() : nullptr); queueTaskKeepingObjectAlive maybe delay the event dispatching in case of page cache. This potentially means that when page exits page cache, it might have user gesture privilege a long time after the actual user gesture. Do we want that? Also, it seems a page could do ping pong postMessage between window and worker to keep user gesture privilege for a potentially long time. Is that what we want? Should we instead move to a timer-based approach like how HTML defines transient activation?
Eric Carlson
Comment 5 2022-04-27 07:14:10 PDT
Comment on attachment 458386 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=458386&action=review >> Source/WebCore/workers/WorkerMessagingProxy.cpp:143 >> + UserGestureIndicator userGestureIndicator(userGestureForwarder ? userGestureForwarder->userGestureToForward() : nullptr); > > queueTaskKeepingObjectAlive maybe delay the event dispatching in case of page cache. > This potentially means that when page exits page cache, it might have user gesture privilege a long time after the actual user gesture. Do we want that? > > Also, it seems a page could do ping pong postMessage between window and worker to keep user gesture privilege for a potentially long time. > Is that what we want? Should we instead move to a timer-based approach like how HTML defines transient activation? I came back to suggest the same thing - shouldn't we have a user gesture timeout for workers like we do for XHR and Fetch?
Jer Noble
Comment 6 2022-04-27 12:51:51 PDT
(In reply to Eric Carlson from comment #5) > Comment on attachment 458386 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=458386&action=review > > >> Source/WebCore/workers/WorkerMessagingProxy.cpp:143 > >> + UserGestureIndicator userGestureIndicator(userGestureForwarder ? userGestureForwarder->userGestureToForward() : nullptr); > > > > queueTaskKeepingObjectAlive maybe delay the event dispatching in case of page cache. > > This potentially means that when page exits page cache, it might have user gesture privilege a long time after the actual user gesture. Do we want that? > > > > Also, it seems a page could do ping pong postMessage between window and worker to keep user gesture privilege for a potentially long time. > > Is that what we want? Should we instead move to a timer-based approach like how HTML defines transient activation? > > I came back to suggest the same thing - shouldn't we have a user gesture > timeout for workers like we do for XHR and Fetch? Okay, seems totally reasonable. I'll adopt the existing maximumIntervalForUserGestureForwarding duration for this.
Jer Noble
Comment 7 2022-04-28 11:25:12 PDT
Created attachment 458538 [details] Patch for landing
Jer Noble
Comment 8 2022-05-05 08:39:10 PDT
Created attachment 458876 [details] Patch for landing
Jer Noble
Comment 9 2022-05-05 11:35:51 PDT
Created attachment 458899 [details] Patch for landing
EWS
Comment 10 2022-05-06 09:30:38 PDT
Committed r293896 (?): <https://commits.webkit.org/r293896> All reviewed patches have been landed. Closing bug and clearing flags on attachment 458899 [details].
Note You need to log in before you can comment on or make changes to this bug.