Bug 138394 - [Mac] media/track/audio-track.html is flakey
Summary: [Mac] media/track/audio-track.html is flakey
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-04 18:04 PST by Jer Noble
Modified: 2014-11-12 10:40 PST (History)
7 users (show)

See Also:


Attachments
Patch (7.73 KB, patch)
2014-11-05 01:10 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (7.67 KB, patch)
2014-11-10 14:44 PST, Jer Noble
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2014-11-04 18:04:41 PST
[Mac] media/track/audio-track.html is flakey
Comment 1 Jer Noble 2014-11-05 01:10:07 PST
Created attachment 241010 [details]
Patch
Comment 2 Alexey Proskuryakov 2014-11-05 09:42:18 PST
Anders, is there an existing message queue class that should be used instead? I feel like we have too many. MessageQueue? Document::postTask?
Comment 3 Jer Noble 2014-11-05 10:24:27 PST
(In reply to comment #2)
> Anders, is there an existing message queue class that should be used
> instead? I feel like we have too many. MessageQueue?

MessageQueue isn't really for Events, but more for cross-thread messaging.

> Document::postTask?

I don't think we should re-use Document::postTask() for this. It does not guarantee ordering across ScriptExecutionContexts.

Ideally, Sam's work to add official task queues <http://www.w3.org/TR/html5/webappapis.html#task-queue> would add a specific Event task queue, which would replace GenericEventQueue, and would be tied to a Browsing Context.

I can add a FIXME to this effect.
Comment 4 Jer Noble 2014-11-05 10:26:54 PST
(In reply to comment #3)
> Ideally, Sam's work to add official task queues
> <http://www.w3.org/TR/html5/webappapis.html#task-queue> would add a specific
> Event task queue, which would replace GenericEventQueue, and would be tied
> to a Browsing Context.

In fact, GenericEventQueue could become the basis for the Event Task Queue.
Comment 5 Alexey Proskuryakov 2014-11-05 10:37:41 PST
> I don't think we should re-use Document::postTask() for this. It does not guarantee ordering across ScriptExecutionContexts.

This actually sounds like a good thing - documents are isolated, and adding a shared event queue would be a side channel for XSS. It obviously wouldn't be the biggest one, so it's not a show stopper in any way, however it surprises me if that's a desirable behavior.
Comment 6 Jer Noble 2014-11-05 10:47:45 PST
(In reply to comment #5)
> > I don't think we should re-use Document::postTask() for this. It does not guarantee ordering across ScriptExecutionContexts.
> 
> This actually sounds like a good thing - documents are isolated, and adding
> a shared event queue would be a side channel for XSS. It obviously wouldn't
> be the biggest one, so it's not a show stopper in any way, however it
> surprises me if that's a desirable behavior.

Hm, maybe.
Comment 7 Jer Noble 2014-11-05 10:51:17 PST
(In reply to comment #6)
> (In reply to comment #5)
> > > I don't think we should re-use Document::postTask() for this. It does not guarantee ordering across ScriptExecutionContexts.
> > 
> > This actually sounds like a good thing - documents are isolated, and adding
> > a shared event queue would be a side channel for XSS. It obviously wouldn't
> > be the biggest one, so it's not a show stopper in any way, however it
> > surprises me if that's a desirable behavior.
> 
> Hm, maybe.

Actually, the spec specifies a minimum of one event loop (and Event task queue) per User Agent, and _allows_ for one event loop per Browsing Context, but does not require it.

So it may be a good idea to segregate event loops on a Browsing Context (i.e. Document) basis, it's not necessary according to the spec.

<http://www.w3.org/TR/html5/webappapis.html#event-loops>
Comment 8 Jer Noble 2014-11-05 11:20:50 PST
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #5)
> > > > I don't think we should re-use Document::postTask() for this. It does not guarantee ordering across ScriptExecutionContexts.
> > > 
> > > This actually sounds like a good thing - documents are isolated, and adding
> > > a shared event queue would be a side channel for XSS. It obviously wouldn't
> > > be the biggest one, so it's not a show stopper in any way, however it
> > > surprises me if that's a desirable behavior.
> > 
> > Hm, maybe.
> 
> Actually, the spec specifies a minimum of one event loop (and Event task
> queue) per User Agent, and _allows_ for one event loop per Browsing Context,
> but does not require it.
> 
> So it may be a good idea to segregate event loops on a Browsing Context
> (i.e. Document) basis, it's not necessary according to the spec.
> 
> <http://www.w3.org/TR/html5/webappapis.html#event-loops>

And, under a close reading of the spec, at a minimum Events must be dispatched in enqueued order across same-origin Browsing Contexts.
Comment 9 Jer Noble 2014-11-10 14:44:48 PST
Created attachment 241308 [details]
Patch
Comment 10 Alexey Proskuryakov 2014-11-12 10:10:38 PST
Comment on attachment 241308 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=241308&action=review

> Source/WebCore/dom/GenericEventQueue.cpp:33
> +#include <wtf/text/CString.h>

Is this include needed?

> Source/WebCore/dom/GenericEventQueue.cpp:66
> +    static NeverDestroyed<Timer> timer(GenericEventQueue::sharedTimerFired);

Please add an ASSERT(isMainThread()) here. The last thing we need is for this to get used from a secondary thread.

> Source/WebCore/dom/GenericEventQueue.cpp:88
> +    static NeverDestroyed<Deque<WeakPtr<GenericEventQueue>>> queues;

Please add an ASSERT(isMainThread()) here, too.
Comment 11 Jer Noble 2014-11-12 10:36:25 PST
Comment on attachment 241308 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=241308&action=review

>> Source/WebCore/dom/GenericEventQueue.cpp:33
>> +#include <wtf/text/CString.h>
> 
> Is this include needed?

No, it's not. I had logging in this file previously, but removed it before uploading. I'll remove this include as well.

>> Source/WebCore/dom/GenericEventQueue.cpp:66
>> +    static NeverDestroyed<Timer> timer(GenericEventQueue::sharedTimerFired);
> 
> Please add an ASSERT(isMainThread()) here. The last thing we need is for this to get used from a secondary thread.

Ok.

>> Source/WebCore/dom/GenericEventQueue.cpp:88
>> +    static NeverDestroyed<Deque<WeakPtr<GenericEventQueue>>> queues;
> 
> Please add an ASSERT(isMainThread()) here, too.

Ok.
Comment 12 Jer Noble 2014-11-12 10:40:49 PST
Committed r176024: <http://trac.webkit.org/changeset/176024>