WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
189619
[EME] Queue a "message" Event algorithm should enqueue a task
https://bugs.webkit.org/show_bug.cgi?id=189619
Summary
[EME] Queue a "message" Event algorithm should enqueue a task
Xabier Rodríguez Calvar
Reported
2018-09-14 07:47:43 PDT
This will a remaining problem of fixing
bug 185590
. Got a fix for it already.
Attachments
Patch
(1.96 KB, patch)
2018-09-14 07:51 PDT
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Patch
(9.45 KB, patch)
2018-09-18 04:12 PDT
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Patch
(12.33 KB, patch)
2018-09-20 08:58 PDT
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Patch
(16.41 KB, patch)
2018-09-21 03:49 PDT
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Xabier Rodríguez Calvar
Comment 1
2018-09-14 07:51:34 PDT
Created
attachment 349759
[details]
Patch
Xabier Rodríguez Calvar
Comment 2
2018-09-18 04:12:36 PDT
Created
attachment 350012
[details]
Patch
Philippe Normand
Comment 3
2018-09-18 04:59:24 PDT
Comment on
attachment 350012
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=350012&action=review
> LayoutTests/media/encrypted-media/mock-MediaKeySession-remove-expected.txt:40 > Promise resolved OK > RUN(promise = mediaKeySession.remove()) > +EXPECTED (event.messageType == 'license-request') OK
This looks odd.
Xabier Rodríguez Calvar
Comment 4
2018-09-18 05:49:35 PDT
(In reply to Philippe Normand from
comment #3
)
> Comment on
attachment 350012
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=350012&action=review
> > > LayoutTests/media/encrypted-media/mock-MediaKeySession-remove-expected.txt:40 > > Promise resolved OK > > RUN(promise = mediaKeySession.remove()) > > +EXPECTED (event.messageType == 'license-request') OK > > This looks odd.
Yes, it did to me too when I debugged it but the spec says that promise callbacks are run before any other event handler as they are scheduled as microtasks. Making this change (to make it conformant with the spec) has this side effect in this custom test. generateRequest returns a promise and an fires an license-request event so if you subscribe to the event handler in the promise callback, you're going to get it. If you think (unlike me) that it is a bad idea to have that check there, I can remove that check but the test has to be modified to expect that event before the other.
Xabier Rodríguez Calvar
Comment 5
2018-09-18 09:42:19 PDT
Phil, after our discussion, I think I managed to fix the issues and regressions we talked about. Please, test this if you can. I won't be able to land it until tomorrow unless you want to watch it.
Xabier Rodríguez Calvar
Comment 6
2018-09-18 09:43:06 PDT
(In reply to Xabier Rodríguez Calvar from
comment #5
)
> Phil, after our discussion, I think I managed to fix the issues and > regressions we talked about. Please, test this if you can. I won't be able > to land it until tomorrow unless you want to watch it.
Oops, wrong bug.
Xabier Rodríguez Calvar
Comment 7
2018-09-20 08:58:13 PDT
Created
attachment 350209
[details]
Patch This patch is still WIP, but I accept comments already
Xabier Rodríguez Calvar
Comment 8
2018-09-20 09:00:44 PDT
The problem here for the waiting-for-key test is that the event is arriving before the promise is resolved. Zan thinks we should have a queue for events and tasks and another for "run in parallel" steps but it looks like it blocks everything if I do that. This is the only thing, before any other investigation, that makes things work and besides that, it files a couple more tests.
Jer Noble
Comment 9
2018-09-20 09:51:12 PDT
Comment on
attachment 350209
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=350209&action=review
> Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp:601 > - m_eventQueue.enqueueEvent(WTFMove(messageEvent)); > + m_eventQueue.enqueueTask([this, messageEvent = WTFMove(messageEvent), pendingActivity = makePendingActivity(*this)] { > + dispatchEvent(messageEvent); > + });
This really shouldn't be necessary. GenericEventQueue is implemented with a GenericTaskQueue; this just duplicates that work, without implementing things like ensuring the event's target is unset and without implementing event dispatch suspension. I suspect that some of the other parts of this patch are what's actually fixing this test.
> Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp:712 > + return m_eventQueue.hasPendingTasks() || ActiveDOMObject::hasPendingActivity();
This could just be m_eventQueue.hasPendingEvents()
Jer Noble
Comment 10
2018-09-20 09:54:17 PDT
(In reply to Xabier Rodríguez Calvar from
comment #8
)
> The problem here for the waiting-for-key test is that the event is arriving > before the promise is resolved. Zan thinks we should have a queue for events > and tasks and another for "run in parallel" steps but it looks like it > blocks everything if I do that. This is the only thing, before any other > investigation, that makes things work and besides that, it files a couple > more tests.
Yes, we have a general problem with event and promise ordering. We would need to fully implement the HTML Event Loop spec <
https://html.spec.whatwg.org/multipage/webappapis.html#event-loops
> to fix this generally.
Xabier Rodríguez Calvar
Comment 11
2018-09-21 03:49:48 PDT
Created
attachment 350347
[details]
Patch
Alex Christensen
Comment 12
2021-11-01 12:56:09 PDT
Comment on
attachment 350347
[details]
Patch This has been requesting review for more than one year. If this is still needed, please rebase and re-request review.
Ahmad Saleem
Comment 13
2023-07-27 23:53:47 PDT
We are still failing following WPT Test, which this patch was fixing:
https://wpt.fyi/results/encrypted-media/clearkey-mp4-waiting-for-a-key.https.html?label=master&label=experimental&aligned&q=encrypted-media%2Fclearkey-mp4
https://wpt.fyi/results/encrypted-media/clearkey-mp4-playback-temporary-events.https.html?label=master&label=experimental&aligned&q=encrypted-media%2Fclearkey-mp4
https://wpt.fyi/results/encrypted-media/clearkey-mp4-playback-persistent-license-events.https.html?label=experimental&label=master&aligned&q=encrypted-media%2Fclearkey-mp4
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug